Link to home
Start Free TrialLog in
Avatar of kellyjj
kellyjj

asked on

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
Avatar of grmbl
grmbl

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
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).


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).


Avatar of kellyjj

ASKER

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.  
Then please paste the piece of code which you are using to read. And the piece where you open the port.
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.

Do you read from the same port you write to? Try reading from another computer.
Also make sure that the device does not have a getty set up on it.
ASKER CERTIFIED SOLUTION
Avatar of JYoungman
JYoungman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kellyjj

ASKER

Thanks I thought I might not be setting things up correctly.