LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 08-30-2004, 09:14 AM   #1
Stor_G
Member
 
Registered: Aug 2004
Posts: 50

Rep: Reputation: 15
Question How to simulate incoming character in serial communication?


Hi all,
i once found a way to simulate an incoming character to a serial line using ioctl.
since then, however, my memory has betrayed me and i can't find the code in which i used it nor the website which described the process.
anyone can reference me to some appropriate docs or give an example of doing that?

Thanks.
 
Old 08-31-2004, 12:20 AM   #2
cppkid
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Ubuntu
Posts: 185

Rep: Reputation: 30
I have done a little work in serial communication, I am sorry i can't understand what do you mean by simulate a character. Plz tell me what you want to do, I will try if i can solve your problem.
 
Old 08-31-2004, 08:28 AM   #3
Stor_G
Member
 
Registered: Aug 2004
Posts: 50

Original Poster
Rep: Reputation: 15
suppose i want to read data from a serial communication which is connected to another computer.
Code:
read(FileDescriptor, &Buffer, BuffSize);
and now another process on the first computer wants to send data through the serial line but to itself, the process won't be able to use
Code:
write(FileDescriptor, Data, sizeof(Data));
because it will arrive to the other computer.
so there's a way to use ioctl with a certain option that is specific to termio architecture. i found yesterday something that might be it, but haven't tested it yet.
if you have any idea, your help would be appreciated.

Edit: misuse of words....

Last edited by Stor_G; 08-31-2004 at 08:29 AM.
 
Old 08-31-2004, 09:06 AM   #4
cppkid
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Ubuntu
Posts: 185

Rep: Reputation: 30
May be i don't have enough knowledge of it but till where i got it, its not possible.
Look you have opend a FileDescripter to a serial port let's say ttyS0, and its connect to someother computer, Then how can the computer send data to itself by writing to that serial port which is connect to someother computer and why a process want to use the serial port to send data to itseld that is connected to someother computer.
Quote:
and now another computer want to send data through serial line but to itself
For me it doesn't make sense, I think i didn't have enough knowledge of it, Sorry Buddy.
 
Old 08-31-2004, 09:15 AM   #5
Stor_G
Member
 
Registered: Aug 2004
Posts: 50

Original Poster
Rep: Reputation: 15
i think this is supposed to help
http://man.netbsd.se/?find=tty+4+20
but i haven't had time to test if it works on my distro (RH 7.3)
obviously i'm looking for a portable way to simulate incoming data from the remote computer.
 
Old 09-01-2004, 02:03 AM   #6
Stor_G
Member
 
Registered: Aug 2004
Posts: 50

Original Poster
Rep: Reputation: 15
Didn't work

anyone has an idea on how to do this?
 
Old 09-01-2004, 02:08 AM   #7
cppkid
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Ubuntu
Posts: 185

Rep: Reputation: 30
Stor_G !!! Sorry for asking again and again but can you tell me why you want to use the same port to send data to some other computer and to send data to itself.
And when that prot is connected to some other computer HOW can you send data through this port to itself and why???
Whatever you will write on that port will be written to the TX pin of serial port and that TX is connected to RX of other computer, not the RX of itself then how can the data be recieved by the computer itself???
 
Old 09-01-2004, 02:22 AM   #8
Stor_G
Member
 
Registered: Aug 2004
Posts: 50

Original Poster
Rep: Reputation: 15
well, there's a program that communicates with a device using serial communication.
there's another process the monitors some information and according to that info has to simulate as if the device sent some certain signals through the serial line.
i was hoping that some kind of internal buffers loopback was possible using ioctl or another method. (that way you don't actually use the serial port itself but send the data directly into the input buffer)

but so far i have only found one that works with terminal windows.
i figured maybe i could use this to simulate serial comm which is implemented similarity. however, that didn't work and i got a bad file descriptor error...

any ideas?


Edit: where did that sentence come from?

Last edited by Stor_G; 09-01-2004 at 02:24 AM.
 
  


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
serial port communication prems Linux - Newbie 1 04-17-2005 02:31 AM
serial port communication vidyaraj Linux - Software 2 03-14-2004 11:32 PM
serial port communication vidyaraj Linux - Software 6 03-02-2004 06:46 PM
communication via serial port perdesiz Linux - Software 0 11-13-2003 06:23 AM
Serial communication - minicom sg3 Linux - Networking 0 07-17-2003 12:00 AM

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

All times are GMT -5. The time now is 05:57 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