LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-13-2006, 03:02 PM   #1
MikeGra
LQ Newbie
 
Registered: Apr 2006
Posts: 2

Rep: Reputation: 0
Serial Port Programming/virtual Device


Hello,

i have to create a virtual com device which is listening on a com port. There is an existing software which
connects to the com port and sends out commands and receives some data. Now my software should act
like the real device and i was wondering how to do this.
Is it possible to read and write on one com port for more than two programs(i don't think so, but perhaps... )
or should i connect each program (the existing one and the emulator) to a ttySx device and then somehow
connect both of these ports?
If this is possible please let me know. I found something about serial/net redirection, but i think thats not
suitable for my needs.

Thanks, Mike
 
Old 04-14-2006, 04:21 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
I think that the simpliest solution is to write a daemon that opens something (Unix domain socket looks like the best solution) for the existing software to use. The daemon also opens the real port and copies the data between the two.

You can also always make it a driver, but that's (a bit) more complicated.
 
Old 04-15-2006, 10:18 AM   #3
MikeGra
LQ Newbie
 
Registered: Apr 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Hello,

thanks for your reply Mara. The problem is that the existing software can only connect to a com port. So
how can i tell the software to access the domain or tcp socket? With these serial port to tcp converters?
I can't rewrite the software because it's closed source and so i'm bound to a com port.
Let's say i use such a serial2tcp converter, can this tool listen on a com port where only software has
access to? As far as i understand you can only reroute serial data from serial devices to a tcp socket.
But i need the data which the program sends to the com port and i want to send data back to the program
without using any external cable or so.

Thanks, Mike
 
Old 04-16-2006, 03:35 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
I'm not thinking about TCP/UDP sockets. It would require a rewrite. Instead, using Unix domain socket requires you only to force the program to connect to /tmp/vport (or a different name) instead of /dev/ttyS0 (or similar). If the file is in fact a socket, basic operations should work. Things like changing speed etc would cause problems, unfortunately. But first check if it allows you to connect to something differnet than /dev/ttySX.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
serial port programming: Java or C? ar1 Programming 5 05-19-2005 02:55 PM
serial port programming!!! novice_din Programming 4 02-03-2005 08:50 PM
Virtual serial port over TCP/IP ericcarlson Linux - Software 0 11-10-2004 05:39 AM
Serial port communication programming SeanatIL Programming 3 07-17-2004 08:26 PM
Programming the Serial Port karans Linux - Networking 2 11-03-2003 01:54 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:32 PM.

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