J
Jim Backus
Guest
The serial interface part of a small Rexx program has got me
completely stuck.
What I want to do is read data from a unit that sends temperature
readings at a regular interval and save reformated data to a file. It
is my intention to use an old 486 PC, running PC Dos 7, to record data
over several days or weeks.
The temperature measuring module has 4 channels and sends data in one
line per channel in the form "1 0016.53" with a single linefeed
character (0A) at the end of line; in the example 1 is the channel
number and 0016.53 is the temperature reading. The unit sends data at
2400 bps, 8 bits, no parity, 1 stop bit - hardly a demanding
interface. The only thing that is non-preferred is that the unit sends
its data single ended rather than as a true RS232 signal.
The problem is that while a terminal emulator can read and display the
data continuously and without apparent problems, my Rexx program
refuses to read a single character. I've never done this sort of thing
in Rexx before so there is probably a simple fundamental error. Any
help or advice would be welcomed. I've tried the program both on an
old 486 running PC Dos 7 Rexx and on a IBM Thinkpad 600E running
Windows 98 and Regina. Both behave the same so I don't think this is a
hardware problem.
As you can see from the program listing below, I've tried both Charin
and Linein functions - both fail to receive any data. The version
below has the Linein section commented out. The program listing
follows:
port = 'COM1'
temp1 = 1.0
temp2 = 2.0
temp3 = 3.0
temp4 = 4.0
Call Stream port, 'C', 'OPEN'
'mode' port||': 24,N,8,1 >NUL'
today = Date('S')
today = Left(today,4)||'-'||SubStr(today,5,2)||'-'||Right(today,2)
now = Time()
then = now
Say today
instr=''
Do until Pos('.', instr)<>0
end /* do */
charvalue = CharIn(port)
instr = instr||charvalue
end /* do */
Say 'Received data was ' instr
/* Do count=1 to 10
instr = LineIn(port)
Say instr
channel = word(instr,1)
Select
when channel = 1 then
temp1 = word(instr,2)
when channel = 2 then
temp2 = word(instr,2)
when channel = 3 then
temp3 = word(instr,2)
when channel = 4 then
temp4 = word(instr,2)
otherwise
temp5 = 'none'
end /* select */
Say now temp1 temp2 temp3 temp4
End */
Thanks for reading this.
Jim
--
Jim Backus OS/2 user since 1994
bona fide replies to j <dot> backus <the circle thingy> jita <dot>
demon <dot> co <dot> uk
completely stuck.
What I want to do is read data from a unit that sends temperature
readings at a regular interval and save reformated data to a file. It
is my intention to use an old 486 PC, running PC Dos 7, to record data
over several days or weeks.
The temperature measuring module has 4 channels and sends data in one
line per channel in the form "1 0016.53" with a single linefeed
character (0A) at the end of line; in the example 1 is the channel
number and 0016.53 is the temperature reading. The unit sends data at
2400 bps, 8 bits, no parity, 1 stop bit - hardly a demanding
interface. The only thing that is non-preferred is that the unit sends
its data single ended rather than as a true RS232 signal.
The problem is that while a terminal emulator can read and display the
data continuously and without apparent problems, my Rexx program
refuses to read a single character. I've never done this sort of thing
in Rexx before so there is probably a simple fundamental error. Any
help or advice would be welcomed. I've tried the program both on an
old 486 running PC Dos 7 Rexx and on a IBM Thinkpad 600E running
Windows 98 and Regina. Both behave the same so I don't think this is a
hardware problem.
As you can see from the program listing below, I've tried both Charin
and Linein functions - both fail to receive any data. The version
below has the Linein section commented out. The program listing
follows:
port = 'COM1'
temp1 = 1.0
temp2 = 2.0
temp3 = 3.0
temp4 = 4.0
Call Stream port, 'C', 'OPEN'
'mode' port||': 24,N,8,1 >NUL'
today = Date('S')
today = Left(today,4)||'-'||SubStr(today,5,2)||'-'||Right(today,2)
now = Time()
then = now
Say today
instr=''
Do until Pos('.', instr)<>0
end /* do */
charvalue = CharIn(port)
instr = instr||charvalue
end /* do */
Say 'Received data was ' instr
/* Do count=1 to 10
instr = LineIn(port)
Say instr
channel = word(instr,1)
Select
when channel = 1 then
temp1 = word(instr,2)
when channel = 2 then
temp2 = word(instr,2)
when channel = 3 then
temp3 = word(instr,2)
when channel = 4 then
temp4 = word(instr,2)
otherwise
temp5 = 'none'
end /* select */
Say now temp1 temp2 temp3 temp4
End */
Thanks for reading this.
Jim
--
Jim Backus OS/2 user since 1994
bona fide replies to j <dot> backus <the circle thingy> jita <dot>
demon <dot> co <dot> uk