LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-30-2010, 08:46 AM   #1
maveq
LQ Newbie
 
Registered: Jul 2010
Posts: 7

Rep: Reputation: 1
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
 
Old 07-30-2010, 10:36 AM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
The navagation software doesn't support anything but direct serial connection for the GPS?
 
Old 07-30-2010, 10:44 AM   #3
maveq
LQ Newbie
 
Registered: Jul 2010
Posts: 7

Original Poster
Rep: Reputation: 1
No, I have to define a com (serial) port in the navigation software (which I am running with wine).
 
Old 07-30-2010, 11:09 AM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
From man gpspipe
Code:
-s     option causes the collected data to be written to the specified
       serial device with setttings 4800 8N1. Thus gpspipe can be used with -s
       and -r options to emulate a serial port hardwired to a GPS that gpsd is
       managing.
And you are using wine (which I know next to nothing about), but maybe try something like this

Code:
gpspipe -r -s ~/.wine/dosdevices/com1
Then see if your windows program can use com1 as a gps receiver

Last edited by tredegar; 07-30-2010 at 11:11 AM. Reason: edited the ~/.wine path
 
Old 07-30-2010, 11:44 AM   #5
maveq
LQ Newbie
 
Registered: Jul 2010
Posts: 7

Original Poster
Rep: Reputation: 1
I have tried that.
Code:
gpspipe -r -s /dev/ttyS0
and I linked /home/ravenous/.wine/dosdevices/com2 to /dev/ttyS0
but '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 
gpspipe: error reading serial port settings
I suppose this is because ttyS0 is a real port. I probably would be able to read from it, if I connected it to another computer and read that other computer's serial port.
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.
 
Old 07-30-2010, 01:40 PM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
I have tried that.
OK, so what happened?
Quote:
and I linked /home/ravenous/.wine/dosdevices/com2 to /dev/ttyS0
I don't think that is going to help, just telling gpspipe to send the data to /home/ravenous/.wine/dosdevices/com2 should be enough. Better to remove that link before you find it complicating things.
Quote:
gpspipe: error reading serial port settings
I see you are running gpspipe as yourself. That's OK, but what are the permissions on /dev/ttyS1 (where you have a node, but no real device) and what groups are you in?
Code:
ls -l /dev/ttyS1
groups
It would also be useful to know what distro you are running

On 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".
 
Old 07-30-2010, 02:29 PM   #7
maveq
LQ Newbie
 
Registered: Jul 2010
Posts: 7

Original Poster
Rep: Reputation: 1
Quote:

I don't think that is going to help, just telling gpspipe to send the data to /home/ravenous/.wine/dosdevices/com2 should be enough. Better to remove that link before you find it complicating things.
~/.wine/dosdevices/com2 is just a symlink to /dev/ttyS0 or /dev/ttyUSB0
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 see you are running gpspipe as yourself. That's OK, but what are the permissions on /dev/ttyS1 (where you have a node, but no real device) and what groups are you in?
It would also be useful to know what distro you are running
/dev/ttyS1 is rw for dialout group, which ravenous belongs to.
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?
 
Old 07-31-2010, 05:00 AM   #8
maveq
LQ Newbie
 
Registered: Jul 2010
Posts: 7

Original Poster
Rep: Reputation: 1
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,raw
and create a link to /home/ravenous/pty in ~/.wine/dosdevices
Now I can use gpsd and my navigation software simultaneously.
All in all, an easy solution.

Thank you.
 
1 members found this post helpful.
Old 07-31-2010, 05:14 AM   #9
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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
 
Old 07-31-2010, 05:41 AM   #10
maveq
LQ Newbie
 
Registered: Jul 2010
Posts: 7

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by tredegar View Post
man socat was giving me a headache!
tell me about it
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
emulate slackware install over serial console using kvm/qemu [GOD]Anck Slackware 5 04-05-2009 03:31 AM
linux serial port to router console port connection? frankie_fix Linux - General 3 02-26-2007 09:32 PM
Parallel Port & Serial Port device identification helpmeforlinux Linux - Hardware 3 01-02-2007 01:15 AM
Using serial port card(PCMCIA) with IPAQ running Linux, can't find ttyS0 port d2army Linux - Laptop and Netbook 0 11-12-2005 08:07 PM
Using an USB port as a standard DB9 Serial Port Lsteele Linux - Newbie 1 10-22-2005 09:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration