1. Can't get com port programs to work
- Posted by Ben Logan <wbljr79 at HOTMAIL.COM>
Jan 25, 2000
-
Last edited Jan 26, 2000
Greetings,
I wanted to write two simple programs, one to accept input from the keyboard
and output it to the com port (comout.ex), and the other to accept input
from the com port and output it to the display (comin.ex). (This is all in
DOS.)
So, I hooked my two computers up via a serial cable (on com1 on both
computers), ran comin.ex on one, and comout.ex on t'other. I typed a few
chars on the one running comout.ex, and after a moment received a "critical
error: abort retry fail ignore" message. My write to the com port was
failing.
I know that the hardware is fine because I ran LapLink on them to test it,
and it worked just fine. I've included the two programs. Can anyone tell
me why it won't work?
Thanks in advance,
Ben
----------COMOUT.EX------------------
--Accept input from keyboard and send it to com1
include get.e
include file.e
integer key,fn
fn = open("COM1","ub") --Open com port
if fn = -1 then --Abort if open fails
puts(2,"Unable to open COM port.\n")
abort(1)
end if
while 1 do
key = wait_key() --Get input from the keyboard
if key = 27 then --If it's ESC, then exit
exit
else
puts(fn,key) --Otherwise, send it to com port
end if
end while
close(fn) --Close the com port
puts(1,"All done!\n")
--------------------------------------
-------------COMIN.EX-----------------
--Accept input from com1, and send it to display
integer fn,byte,key
fn = open("COM1","ub") --Open com port
if fn = -1 then --Abort if open fails
puts(2,"Unable to open COM port.\n")
abort(1)
end if
while 1 do
key = get_key() --If a key was pressed,
if key > 0 then --then exit program
exit
end if
byte = getc(fn) --Otherwise, get input from com port
if byte > 0 then --If any input was waiting,
puts(1,byte) --output it to the display
end if
end while
close(fn) --Close the com port
puts(1,"\nAll done!\n")
----------------------------------------------
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
2. Re: Can't get com port programs to work
- Posted by JJProg at CYBERBURY.NET
Jan 25, 2000
-
Last edited Jan 26, 2000
EU>Greetings,
EU>I wanted to write two simple programs, one to accept input from the keyboard
EU>and output it to the com port (comout.ex), and the other to accept input
EU>from the com port and output it to the display (comin.ex). (This is all in
EU>DOS.)
EU>So, I hooked my two computers up via a serial cable (on com1 on both
EU>computers), ran comin.ex on one, and comout.ex on t'other. I typed a few
EU>chars on the one running comout.ex, and after a moment received a "critical
EU>error: abort retry fail ignore" message. My write to the com port was
EU>failing.
EU>I know that the hardware is fine because I ran LapLink on them to test it,
EU>and it worked just fine. I've included the two programs. Can anyone tell
EU>me why it won't work?
EU>Thanks in advance,
EU>Ben
EU>----------COMOUT.EX------------------
EU>--Accept input from keyboard and send it to com1
EU>include get.e
EU>include file.e
EU>integer key,fn
EU>fn = open("COM1","ub") --Open com port
EU>if fn = -1 then --Abort if open fails
EU> puts(2,"Unable to open COM port.\n")
EU> abort(1)
EU>end if
EU>while 1 do
EU> key = wait_key() --Get input from the keyboard
EU> if key = 27 then --If it's ESC, then exit
EU> exit
EU> else
EU> puts(fn,key) --Otherwise, send it to com port
EU> end if
EU>end while
EU>close(fn) --Close the com port
EU>puts(1,"All done!\n")
EU>--------------------------------------
EU>-------------COMIN.EX-----------------
EU>--Accept input from com1, and send it to display
EU>integer fn,byte,key
EU>fn = open("COM1","ub") --Open com port
EU>if fn = -1 then --Abort if open fails
EU> puts(2,"Unable to open COM port.\n")
EU> abort(1)
EU>end if
EU>while 1 do
EU> key = get_key() --If a key was pressed,
EU> if key > 0 then --then exit program
EU> exit
EU> end if
EU> byte = getc(fn) --Otherwise, get input from com port
EU> if byte > 0 then --If any input was waiting,
EU> puts(1,byte) --output it to the display
EU> end if
EU>end while
EU>close(fn) --Close the com port
EU>puts(1,"\nAll done!\n")
EU>----------------------------------------------
EU>______________________________________________________
EU>Get Your Private, Free Email at http://www.hotmail.com
Try using serial.e. I tried accessing serial and parallel ports using
files before, and it didn't work either.
Jeffrey Fielding
JJProg at cyberbury.net
http://members.tripod.com/~JJProg/
3. Re: Can't get com port programs to work
- Posted by Bernie Ryan <bwryan at PCOM.NET>
Jan 25, 2000
-
Last edited Jan 26, 2000
On Tue, 25 Jan 2000 20:03:02 EST, Ben Logan <wbljr79 at HOTMAIL.COM> wrote:
>Greetings,
>
>I wanted to write two simple programs, one to accept input from the
keyboard
>and output it to the com port (comout.ex), and the other to accept input
>from the com port and output it to the display (comin.ex). (This is all in
>DOS.)
>
When you use laplink you are using a program at each end of the cable.
These programs initialize the ports by setting up the baud rates and
manipulate some handshaking bits which syncronize the communications
between the two computers. This is how the computers know if a byte
has been sent or recieved.
You will have to duplicate the way laplink works by using serial.e
like Jeffrey Fielding said. You maybe able to get it to work by using
DOS MODE command to set the parity and baud rate, etc. But that would
only be temporary until you reboot.
Bernie
4. Re: Can't get com port programs to work
- Posted by Ben Logan <wbljr79 at HOTMAIL.COM>
Jan 25, 2000
-
Last edited Jan 26, 2000
I got the two computers to communicate using serial.e, but all I get on the
output (comin.ex) is 30's and 31's. I send the ascii code of the key I
press (using comout.ex), but always get a 30 or 31 (and maybe a 28) on the
other computer. I've included the modified files.
Thanks again,
Ben
-----------------COMOUT.EX---------------------
--Accept input from keyboard and send it to com1
include get.e
include serial.e
integer key
while 1 do
key = wait_key() --Get input from the keyboard
if key = 27 then --If it's ESC, then exit
exit
else
SendSerialByte(1,key)
end if
end while
puts(1,"All done!\n")
--------------------------------------------
-----------------COMIN.EX-------------------
--Accept input from com1, and send it to display
include serial.e
integer data,key
while 1 do
key = get_key()
if key > 0 then
exit
end if
data = GetSerialByte(1)
if data > 0 then
printf(1,"%d",{data})
end if
end while
puts(1,"\nAll done!\n")
-------------------------------------------
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
5. Re: Can't get com port programs to work
- Posted by JJProg at CYBERBURY.NET
Jan 25, 2000
-
Last edited Jan 26, 2000
EU>I got the two computers to communicate using serial.e, but all I get on the
EU>output (comin.ex) is 30's and 31's. I send the ascii code of the key I
EU>press (using comout.ex), but always get a 30 or 31 (and maybe a 28) on the
EU>other computer. I've included the modified files.
EU>Thanks again,
EU>Ben
EU>-----------------COMOUT.EX---------------------
EU>--Accept input from keyboard and send it to com1
EU>include get.e
EU>include serial.e
EU>integer key
EU>while 1 do
EU> key = wait_key() --Get input from the keyboard
EU> if key = 27 then --If it's ESC, then exit
EU> exit
EU> else
EU> SendSerialByte(1,key)
EU> end if
EU>end while
EU>puts(1,"All done!\n")
EU>--------------------------------------------
EU>-----------------COMIN.EX-------------------
EU>--Accept input from com1, and send it to display
EU>include serial.e
EU>integer data,key
EU>while 1 do
EU> key = get_key()
EU> if key > 0 then
EU> exit
EU> end if
EU> data = GetSerialByte(1)
EU> if data > 0 then
EU> printf(1,"%d",{data})
EU> end if
EU>end while
EU>puts(1,"\nAll done!\n")
EU>-------------------------------------------
EU>______________________________________________________
EU>Get Your Private, Free Email at http://www.hotmail.com
First, make sure both computers are using the same baud, parity, data,
and stop bits using GetPortBPDS and SetPortBPDS. Also, check that you
have the right kind of cable - some switch the wires around, and others
don't.
Jeff
JJProg at cyberbury.net
http://members.tripod.com/~JJProg/