Serial port access from Linux...

Posted by: andym

Serial port access from Linux... - 16/07/2002 13:41

Hello,

Could someone point me in the direction of some simple code that would allow me to read data from the docked serial port whilst the player app is running. I don't actually need full read/write access, simply to be able to listen to the data coming out of my GPS reciever.
Posted by: wfaulk

Re: Serial port access from Linux... - 16/07/2002 13:56

Ahh, the always popular world of Unix serial programming. While I've not done it on the empeg, (and it might be different since there's otehr stuff happening on the serial port), the following guides I've always found to be useful:

http://www.easysw.com/~mike/serial/serial.html
http://www.stokely.com/unix.serial.port.resources/serial.card.code.html#code.link (toward the bottom)
http://astronomy.swin.edu.au/~pbourke/other/serial/

I'm sure you can find more by searching for ``Unix Serial Programming'' on your favorite search engine.
Posted by: andym

Re: Serial port access from Linux... - 16/07/2002 14:21

Thanks, I'm sure that'll do the trick. Do you think there could be a problem trying to listen to the com port while the player app is running. From looking at the code it looks like I'm just opening a file and reading the contents.

Now, next problem is to try and get a polling loop inside my Hijack userland program to work. At the moment it looks like the program waits until a button has been pressed and then continues execution, any way around this?
Posted by: wfaulk

Re: Serial port access from Linux... - 16/07/2002 14:43

There might be a problem with getting your code and the player to work with the serial port at the same time. I'm not sure if the player will prevent reads. I'm pretty sure there's an option you can give the player software to get it to stop dealing with the serial port, but I forget what it is right now. Maybe it's in the developer section of riocar.org?

And what do you mean with your ``polling loop'' question? You mean that your read is blocking for input (that is, not progressing any further unless the read() has something to return)? You might want to look at the select() function call. You can also apply timeouts to certain things; maybe an ioctl()? I think one of those documents talks about it at least a little.
Posted by: kirkis

Re: Serial port access from Linux... - 16/07/2002 15:37

In reply to:

Now, next problem is to try and get a polling loop inside my Hijack userland program to work. At the moment it looks like the program waits until a button has been pressed and then continues execution, any way around this?




I had the same problem. You can get around this with the ioctl EMPEG_HIJACK_POLLBUTTONS.

It is briefly discussed in this thread:

http://empeg.comms.net/php/showthreaded.php?Cat=&Board=hackers_prog&Number=43891&page=&view=&sb=&o=

I couldn't find much in the way of documentation, but with a bit of experimentation I got it to work properly. I'm hoping to release code within a few weeks that will demonstrate its use.