Open driver "COM1:" fails

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pstary
Posts: 4
Joined: Mon Aug 12, 2024 4:48 pm
Contact:

Open driver "COM1:" fails

Post by pstary » Mon Aug 12, 2024 9:35 pm

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?
Paul Stary
Audio-Video Engineering

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

Re: Open driver "COM1:" fails

Post by richmond62 » Mon Aug 12, 2024 10:42 pm

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?
Last edited by richmond62 on Tue Aug 13, 2024 10:34 am, edited 1 time in total.

pstary
Posts: 4
Joined: Mon Aug 12, 2024 4:48 pm
Contact:

Re: Open driver "COM1:" fails

Post by pstary » Mon Aug 12, 2024 10:58 pm

I forgot to include I am using LiveCode v9-6-11.
Paul Stary
Audio-Video Engineering

pstary
Posts: 4
Joined: Mon Aug 12, 2024 4:48 pm
Contact:

Re: Open driver "COM1:" fails

Post by pstary » Mon Aug 12, 2024 11:04 pm

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!
Paul Stary
Audio-Video Engineering

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1232
Joined: Thu Apr 11, 2013 11:27 am

Re: Open driver "COM1:" fails

Post by LCMark » Tue Aug 13, 2024 5:38 am

@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"

AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Re: Open driver "COM1:" fails

Post by AndyP » Tue Aug 13, 2024 9:40 am

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
Andy .... LC CLASSIC ROCKS!

pstary
Posts: 4
Joined: Mon Aug 12, 2024 4:48 pm
Contact:

Re: Open driver "COM1:" fails

Post by pstary » Tue Aug 13, 2024 3:56 pm

That did it! Thank you very much.
Paul Stary
Audio-Video Engineering

Post Reply