![]() |
clone/emulate serial port
Hello
I have a usb gps receiver. The navigation program I use, uses the serial port directly. Now I would like to use another program e.g. gpsd to use the same data that comes from the serial port, simultaneously with my navigation program. But only one program at a time can use the port. So I am looking for a way to clone the serial port. Or any other way I can use two (or more) programs reading from the same serial port. I can let gpsd use the gps serial port and use gpspipe to connect to gpsd and that way I can get the data I need (as standard output) , but I still need a way to make my navigation program use that data. I won't necessarily have a hardware serial port (rs-232) on the machine. Benjamin |
The navagation software doesn't support anything but direct serial connection for the GPS?
|
No, I have to define a com (serial) port in the navigation software (which I am running with wine).
|
From man gpspipe
Code:
-s option causes the collected data to be written to the specifiedCode:
gpspipe -r -s ~/.wine/dosdevices/com1 |
I have tried that.
Code:
gpspipe -r -s /dev/ttyS0but 'cat /dev/ttyS0' or 'gpscat /dev/ttyS0' gave nothing and my navigation software couldn't find it either. On this machine, I do have one real serial port /dev/ttyS0. Using anything else gives the following error. Code:
ravenous@square:~/gpsd-2.92$ ./gpspipe -r -s /dev/ttyS1 That is why I need to emulate a serial port, I think. Or if there is a way to loopback ttyS0, so that you can read everything you write to it, but I haven't found anything in the setserial manual. |
Quote:
Quote:
Quote:
Code:
ls -l /dev/ttyS1On another track: Maybe, as you are using wine, life would be easier if you were not running gpsd at all. What happens if you kill gpsd and then symlink /dev/ttyUSB0 (where the GPS device is) to /home/ravenous/.wine/dosdevices/com2 Wine / windows program should say "com2 is a COM port, with a GPS receiver spitting out NMEA data, I'll use it". |
Quote:
It is the way wine accesses serial devices. If I should remove the link, what kind of file should ~/.wine/dosdevices/com2 be? It is not automatically created by wine. This is how my navigation software can use /dev/ttyUSB0, which is my gps receiver and this way the navigation software can use the gps receiver just fine. But the problem is that I want to use my navigation software on one hand, and use gpsd on the other, running side by side; both using the same gps receiver. Quote:
I tried running gpspipe as root and using sudo, but I get the same message. I am using Kubuntu 10.04 I have read several things about socat and remserial. I just came up with an idea. Creating a stream with socat between my gps receiver and a network port. Then creating two other streams that connect between that network port and two PTY's, which according to the manual, can be accessed as a serial line. But I don't know socat, so maybe someone has some suggestions about this? |
I have found a way to do what I want.
I let gpsd use the gps receiver and then use the following Code:
gpspipe -r | socat - PTY,link=/home/ravenous/pty,rawNow I can use gpsd and my navigation software simultaneously. All in all, an easy solution. Thank you. |
Brilliant!
I was about to refer you to this page where they seem to have solved it with a php script and a fifo pipe, when you posted the above. The script I linked probably won't work with the latest version of gpsd anyway. But your fix is more elegant, easier and probably the "right" way to do it. man socat was giving me a headache! Thanks for posting the solution :) |
Quote:
|
| All times are GMT -5. The time now is 12:48 PM. |