---- Rick T <[email protected]> wrote:
>
> #define STX 0x02
> #define ETX 0x03
it is a function of type integer called calculate_lrc. There is an
input pointer to a string called packet.
> short int calculate_lrc(char *packet)
> {
define variables
> char *lrc_ptr;
> short int lrc = 0;
assign the lrc_ptr (pointer) to the first character of the packet string
> lrc_ptr = packet;
>
If the first character is a STX (start transmission x02, return with a failure
value of -1
> if( ! (lrc_ptr = strchr (lrc_ptr, STX )) )
> return (-1);
Add one to the pointer
> ++lrc_ptr;
start a do while loop
> do {
assign the lrc variable to the current pointer address plus one character
> lrc ^= *lrc_ptr++;
check to see if the next character is the end of transmission character ETX
(x03)
> } while (*lrc_ptr != ETX);
drop out the do while loop when the current character pointed to by the lrc_ptr
is ETX
assign the lrc variable (perhaps "last received character" with the char
pointed to by the current pointer position
> lrc ^= *lrc_ptr;
return the character
> return lrc;
> }
So my guess after 25+ years of fooling with this sort of thing is
that this function takes a string from the comm port (or other
UART device), lops off the control codes, and sends the last
character in the string to the caller. I am rusty at this and without
context, it is tricky to give you an exact answer.
Of course, I could be completely out to lunch too. No pun intended
as I swallow my burger.
I miss the old days are reading teletype and paper tape codes. I
remember writing C code to do something like this when I was communicating
with a teletype device back when microcomputers came out. It was like
magic.
Got any COBOL you want translated. ;) Good luck, Roger
--
http://www.linkedin.com/pub/roger-austin/8/a4/60
http://twitter.com/RogerTheGeek
http://www.misshunt.com/ Home of the Clean/Dirty Magnet
http://cfinnc.com/ ColdFusion Conference in North Carolina Oct 17-18
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326209
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4