friendly64
Programmer
Hi! , I´m from Monterrey, México and my english may be bad, so please excuse me.
I´m working in a recycler paper company and we need to get the weigth of the paper from the scale indicator, so I need read the entry data by serial port Com1 and I tried to do it using the next code:
DEFINE VARIABLE device AS CHARACTER INITIAL "com1".
DEFINE VARIABLE CharIn AS CHARACTER.
DEFINE VARIABLE aLine AS CHARACTER format "x(50)".
DEFINE VARIABLE lectura AS CHARACTER format "x(300)".
DEFINE STREAM serial.
DEFINE STREAM Term-Port.
define variable t as integer.
define variable x as integer.
define variable varlinea as character format "x(20)".
define variable completo as integer.
define variable cuenta as integer.
INPUT STREAM serial
FROM VALUE(device)
binary no-echo.
t = 1.
REPEAT while t < 1000 :
t = t + 1.
READKEY STREAM serial.
CharIn = CHR(LASTKEY).
aLine = aline + Charin.
IF LASTKEY = 27 or LASTKEY = 13 THEN LEAVE.
END.
INPUT CLOSE.
aline = TRIM(aline).
display aline.
The settings of the port are : Baud rate 2400, Data bits 7, parity even, Stop bits 1. Hyperterminal works with this settings.
We use a Progress v 8.1a and Windows NT .
This code try to read, but the data to retrieve is the code 120 and 0, so it's a wrong read.
Can anybody help me to solve this problem or give me a tip?
I will appreciate your help.
I´m working in a recycler paper company and we need to get the weigth of the paper from the scale indicator, so I need read the entry data by serial port Com1 and I tried to do it using the next code:
DEFINE VARIABLE device AS CHARACTER INITIAL "com1".
DEFINE VARIABLE CharIn AS CHARACTER.
DEFINE VARIABLE aLine AS CHARACTER format "x(50)".
DEFINE VARIABLE lectura AS CHARACTER format "x(300)".
DEFINE STREAM serial.
DEFINE STREAM Term-Port.
define variable t as integer.
define variable x as integer.
define variable varlinea as character format "x(20)".
define variable completo as integer.
define variable cuenta as integer.
INPUT STREAM serial
FROM VALUE(device)
binary no-echo.
t = 1.
REPEAT while t < 1000 :
t = t + 1.
READKEY STREAM serial.
CharIn = CHR(LASTKEY).
aLine = aline + Charin.
IF LASTKEY = 27 or LASTKEY = 13 THEN LEAVE.
END.
INPUT CLOSE.
aline = TRIM(aline).
display aline.
The settings of the port are : Baud rate 2400, Data bits 7, parity even, Stop bits 1. Hyperterminal works with this settings.
We use a Progress v 8.1a and Windows NT .
This code try to read, but the data to retrieve is the code 120 and 0, so it's a wrong read.
Can anybody help me to solve this problem or give me a tip?
I will appreciate your help.