Solved

serial communication programm for UNIX

Posted on 1998-06-10
10
219 Views
Last Modified: 2010-04-15
Ok,  I am trying to write a serial program.  At this point I am just trying to get the port, and dial out to another computer.  I am trying to do this on a SCO UNIX box.  Currently, I am successfully getting the port and setting the atts of it.  ( At least I think I am).  As far as I understand it  All I need to do is do a write to the port, and then I can read from it.  I am correct?  Is there anything I need to do before hand?  Thanks guys
0
Comment
Question by:kellyjj
  • 2
  • 2
  • 2
  • +4
10 Comments
 

Expert Comment

by:grmbl
ID: 1251177
You need to use the ioperm() function to give yourself permission to write/read at that address. Did you do that? And what is the actual problem? You can use inb/oub or you can open /dev/port
0
 
LVL 32

Expert Comment

by:jhance
ID: 1251178
ioperm() and inb/oub are NOT the way to do this.  You can open the port with open(), read it with read() and write it with write().  If you need to set any of it's attributes use one of the termios functions (see man termios).


0
 
LVL 32

Expert Comment

by:jhance
ID: 1251179
ioperm() and inb/oub are NOT the way to do this.  You can open the port with open(), read it with read() and write it with write().  If you need to set any of it's attributes use one of the termios functions (see man termios).


0
 
LVL 2

Author Comment

by:kellyjj
ID: 1251180
I don't have a problem reading from the writing .  What I am having a problem with is reading from the port.  I can write ok.  For example I send to the port (modem)  AT^M  I should see back OK. But I don't.  
0
 

Expert Comment

by:grmbl
ID: 1251181
Then please paste the piece of code which you are using to read. And the piece where you open the port.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 2

Expert Comment

by:seedy
ID: 1251182
I do not have solutions, just a few hints ;-)

> I am successfully getting the port and setting the atts of it.  ( At least I think I am).
What attributes, and how are you setting this?

Use "stty -a < /dev/your_port" to check the current I/O settings for the port in question.  Post the output here.

Use simple unix level commands to check the modem is working fine.

$ cat < /dev/your_port&;cat > /dev/your_port&

and then type AT commands onthe keyboard to see you get response back from the modem.

0
 

Expert Comment

by:mkdjo
ID: 1251183
Do you read from the same port you write to? Try reading from another computer.
0
 
LVL 1

Expert Comment

by:slinky
ID: 1251184
Also make sure that the device does not have a getty set up on it.
0
 
LVL 2

Accepted Solution

by:
JYoungman earned 100 total points
ID: 1251185
If you have set the port up correctly (with termios(3)) then
you can indeed just read from it and write from it.  

Don't let the <stdio.h> bufferring get in your way though -- use either read(2) and write(2), or use setvbuf(3) to turn off buffering if your're using a FILE* rather than a plain fd.

0
 
LVL 2

Author Comment

by:kellyjj
ID: 1251186
Thanks I thought I might not be setting things up correctly.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now