hangs on read from driver...

Deploying to Linux? Get penguinated here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cyb3rg3cko
Posts: 7
Joined: Sun Oct 27, 2013 6:24 am

hangs on read from driver...

Post by cyb3rg3cko » Sun Oct 27, 2013 6:58 am

I am new to LiveCode and this forum but not really to programing. I have been writing an application on my Ubuntu Linux system to cater to a few custom electronic projects that communicate through serial. So far my application works perfectly fine on windows systems but has an issue running on linux systems.

Application Test System: Ubuntu Linux 12.10 64bit
Programming system: Livecode 6.1.2 (Windows 7) as well as 6.1.0 (Ubuntu 12.10 64bit)

I have no trouble opening a port using... (Had worse problems with open for binary update)

Code: Select all

put "/dev/ttyUSB0" into myPort
open driver myPort for text update
And once a connection is established it reads fine using...(im reading one character at a time)

Code: Select all

read from driver myPort for 1
the problem comes when there is no more data to being sent to the port from the device, it seems like if there is no data the program just hangs there until more data is available not being able to close or use any buttons. However once there is more data it once again reads fine.

I have a temporary solution by looking for an end character ( the > sign) that i have programed into my electronic device that drops the program out of the read loop. (See code below)

Code: Select all

on ReadLoop
  read from driver myPort for 1
  if it is not empty then
    put it into CurChar
    put CurChar after field "Output"
    if CurChar <> ">" then send ReadLoop to me in 300 millisecs
  end if
end ReadLoop
However there are some cases that i cant do this. Is this a bug or am I just going about reading it in the wrong way for Linux? I have tried many different methods including 'read until EOF', 'read until empty', and 'read for 1 line'.

Any help is greatly appreciated.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: hangs on read from driver...

Post by Mark » Wed Oct 30, 2013 11:26 pm

Hi,

Your approach is correct. Depending on your binary data, you might want to use NULL instead of left or right tag. What does "can't do this" mean exactly? What happens?

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

cyb3rg3cko
Posts: 7
Joined: Sun Oct 27, 2013 6:24 am

Re: hangs on read from driver...

Post by cyb3rg3cko » Wed Oct 30, 2013 11:54 pm

Thanks for the reply. What i mean by "can't do tha't" is that i can't always program a termination character at the end of my serial reply (the transmission from my electronic device to the livecode program) regardless of what that character is. The concern I have with this method (even using the NULL character) is that the only time i can read from the device is when i'm expecting a reply versus continiously checking to see if there is any characters in the serial buffer. Is this something that is just related to linux or a issue in livecode? I have been using linux for many years but this is my first attempt at programming a serial communication application for it.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: hangs on read from driver...

Post by Mark » Thu Oct 31, 2013 12:00 am

Hi,

I'd say, it is an issue due to LiveCode lacking a timeout for serial ports.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

cyb3rg3cko
Posts: 7
Joined: Sun Oct 27, 2013 6:24 am

Re: hangs on read from driver...

Post by cyb3rg3cko » Thu Oct 31, 2013 12:06 am

But why would it work for windows by exiting once there were no more characters but not linux? Wouldn't a timeout effect all OS's? Plus i would think by using Livecode's l'to=on' in the serial control string would take care of that...

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: hangs on read from driver...

Post by Mark » Thu Oct 31, 2013 12:22 am

Hi,

You're right. Then it must be either a LiveCode or a Linux bug. I can't tell which one it is.

Someone had a similar problem on Mac OS X. You might want to check out this bug.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply

Return to “Linux”