serial communication programm for UNIX

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
LVL 2
kellyjjAsked:
Who is Participating?
 
JYoungmanConnect With a Mentor Commented:
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
 
grmblCommented:
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
 
jhanceCommented:
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
Identify and Prevent Potential Cyber-threats

Become the white hat who helps safeguard our interconnected world. Transform your career future by earning your MS in Cybersecurity. WGU’s MSCSIA degree program was designed in collaboration with national intelligence organizations and IT industry leaders.

 
jhanceCommented:
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
 
kellyjjAuthor Commented:
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
 
grmblCommented:
Then please paste the piece of code which you are using to read. And the piece where you open the port.
0
 
seedyCommented:
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
 
mkdjoCommented:
Do you read from the same port you write to? Try reading from another computer.
0
 
slinkyCommented:
Also make sure that the device does not have a getty set up on it.
0
 
kellyjjAuthor Commented:
Thanks I thought I might not be setting things up correctly.
0
All Courses

From novice to tech pro — start learning today.