Welcome! Log In Create A New Profile

Advanced

Serial communication STX ETX LRC

Posted by Willy 
Serial communication STX ETX LRC
September 05, 2018 10:00AM
Hello

I have to send a a command to a serial device

<STX>00C100000000100007654321                    0000000000501EUR<ETX><LRC>


I do'nt know what those things like STX ETX and LRC mean.

Can someone help me.

Thanks.

Will Hermans
Re: Serial communication STX ETX LRC
September 05, 2018 10:31AM
Hi,

[ascii.cl]

Kind regards,
G. Predl
pao
Re: Serial communication STX ETX LRC
September 05, 2018 10:32AM
Hi Willy,
Normally this are hexadecimal control chars.

You can check one ascii table or the device manual to see the hexadecimal values of this chars.

to send the STX you can use the function Charact(02)
Re: Serial communication STX ETX LRC
September 05, 2018 10:44AM
Thanks,
So simple.

But there is still one problem. There is no LRC in the ascii table.
The documentation says :

LRC = the exclusive or of
00C100000000100007654321                    0000000000501EUR<ETX>

I see no XOR in Windev
Re: Serial communication STX ETX LRC
September 05, 2018 10:50AM
Willy,

that's BinaryXOR() in Windev

Arie
Re: Serial communication STX ETX LRC
September 05, 2018 10:54AM
Thanks
Re: Serial communication STX ETX LRC
September 05, 2018 05:39PM
Varoius control characters

cSTX is character = Charact(02) 
cETX is character = Charact(03)
cACK is character = Charact(06)
cNAK is character = Charact(21)
cFS is character = Charact(28)
cRS is character = Charact(30)

Function to calculate LRC
PROCEDURE get_lrc(LOCAL sString is string)
nLRC is int = 0
nZnak is int 
	//[en.wikipedia.org]
	
FOR nP=1 _TO_ Length(sString)
	nZnak=Asc(Middle(sString,nP,1))
	nLRC=BinaryXOR(nZnak,nLRC)
END

RESULT nLRC

BR,
Alen Uzelac
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: