Page 1 of 1

Open driver "COM1:" fails

Posted: Mon Aug 12, 2024 9:35 pm
by pstary
While this is my first forum post, I have been using LiveCode for decades (SuperCard and HyperCard) and love the product!

I am usually able to sort out problems with the help of this Forum which is the most amazing resource available for LiveCode. However, time and lack of knowledge about serial communication has motivated me to ask for help.

I have confirmed that LiveCode and the port share the same "9600,N,8,1" settings.

I have set up a simple button script to test sending a single "A" character to a Windows 10 PC COM port (COM5 to be exact). Here is the script:

Code: Select all

on mouseUp
   put empty into fld 1
   
   set the serialControlString to "BAUD=9600, PARITY=N, DATA=8, STOP=1"
   
   open driver "COM5:" for write
   put the result into fld 1
   
   write (numToChar(65) & return) to driver "COM5:"
   
   close driver "COM5:"
   
end mouseUp
This ALWAYS has the result, "file is not open for write", no mater what form I try.

I'm using a great app called "Serial Port Monitor" to look at what's happening. See the the first 2 lines of the table it builds from pressing the "Send" button below (I can't send a screenshot because I guess I'm too new?):

164 12/08/2024 10:39:33 IRP_MJ_CREATE DOWN LiveCode(full path shown) COM5
165 12/08/2024 10:39:33 IRP_MJ_CREATE UP STATUS_SUCCESS LiveCode(full path shown) COM5

Why doesn't LiveCode handle this basic serial communication task? Perhaps the venerable "open driver" command cannot negotiate with the UART in the PC to access the USB bus for serial data?

Thanks so much for any suggestions. When will I be able to attach images?

Re: Open driver "COM1:" fails

Posted: Mon Aug 12, 2024 10:42 pm
by richmond62
I have been using LiveCode for decades (SuperCard and HyperCard) and love the product!
I am usually able to sort out problems with the help of this Forum which is the most amazing resource available for LiveCode.
Aha: so why did you only sign up to the forums today?

Re: Open driver "COM1:" fails

Posted: Mon Aug 12, 2024 10:58 pm
by pstary
I forgot to include I am using LiveCode v9-6-11.

Re: Open driver "COM1:" fails

Posted: Mon Aug 12, 2024 11:04 pm
by pstary
I have been meaning to get more involved but enjoy the challenge of solving my own problems.

That said, it's selfish of me to have gained so much from this forum but not share what I have learned. I will try to do better!

Re: Open driver "COM1:" fails

Posted: Tue Aug 13, 2024 5:38 am
by LCMark
@pstary: So I *think* the format of your serial control string is not quite right... The engine first opens the COM port and *then* it tries to parse and apply the serial control string - which would be consistent with you seeing the COM port open but then getting an error in the result in LiveCode.

The serial control string should have the same structure as the 'mode' command - https://learn.microsoft.com/en-us/windo ... mands/mode.

So maybe try without the commas. i.e.

Code: Select all

set the serialControlString to "BAUD=9600 PARITY=N DATA=8 STOP=1"

Re: Open driver "COM1:" fails

Posted: Tue Aug 13, 2024 9:40 am
by AndyP
Yep, no commas in the serial control string

On windows replace driver with file

Code: Select all

on mouseUp
   put empty into fld 1
   
   set the serialControlString to "BAUD=9600 PARITY=N DATA=8 STOP=1"
   
   open file "COM5:" for write
   put the result into fld 1
   
   write (numToChar(65) & return) to file "COM5:"
   
   close file "COM5:"
   
end mouseUp

Re: Open driver "COM1:" fails

Posted: Tue Aug 13, 2024 3:56 pm
by pstary
That did it! Thank you very much.