Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read a continous signal from the port com1

Status
Not open for further replies.

friendly64

Programmer
Mar 6, 2003
2
MX
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.
 
Hi friendly64

Don't worry too much about your English - I'm from England, and our English isn't so good either :)

We have a guy here who used to use Progress to interface to scales which weigh chickens...

Can you just clarify something - what is the string of 7 bit character values which the weighing machine is sending and what is the string of characters that you are seeing? One problem with Progress is that it uses CHR(0) as a string terminator, so it often causes complications.

Regards

EARTHDWELLER
 
Hi EARTHDWELLER

First, thank you for your interest.
Answering your question, the output string from the weighing machine is:

ST,GS,+9999999kg

I can see this output by hyperterminal.

, and the output string that I see by Progress is:

xx|x|xx|x<x|xx<pxx

Ascii characters : 120 , 124 , 60 , 112.

As you can see, does not exist any relation between one output and the other.

What do you recommend me ?

Regards

friendly64
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top