22-RS232++ Parsing Speed
Technical Support Guide
Table of Contents
Brand:
- AMX
Models:
- AXB-232++
Question:
I have a strange error with an AXB-232++ (V3.042 REV B). I receive a string, in this case 4 sets of 5 characters. It could be more characters than in this example.
If I use an AXB-232++ as the receiver, sometimes I see only 17 or 18 characters, but when I receive the same package next time, the missing characters are included with the new string.
With an AXB-232+ (V2.03 REV B)(the GOOD OLD ONE), there isn't this problem.
Here's the code sent for your reference:
WAIT_UNTIL(LENGTH_STRING(ROOM_COM_BUF)>0) (* BUFFER FšR STR. V.ROOM-STR *)
{
ROOM_FIN_STR=FIND_STRING(ROOM_COM_BUF,$00,1)
IF (ROOM_FIN_STR)
{
ROOM_REM_STR=REMOVE_STRING(ROOM_COM_BUF,$00,1)
(* REMOVE STR. POS IN BUFFER *)
ROOM_REM_STR=MID_STRING(ROOM_COM_BUF,1,3)
(* STATUS DEVICE IN ROOM *)
ROOM_STAT[ROOM_REM_STR[1]][ROOM_REM_STR[2]]=(ROOM_REM_STR[3]-48) (* STATUS DEVICE IN ROOM *)
}
}
Answer:
The main difference between the 232++ versus the 232+ is raw speed, particularly as related with how quickly bytes are seen in the buffer.
In the example you sent where you a parsing strings ("$00,$34,$09,'1',$FF") your code only waits until it sees a "$00" in the buffer, the header of the string. It is possible that it may then execute the REMOVE_STRING and MID_STRING before all the following bytes have appeared in the buffer and thus some bytes will be lost in the ROOM_STAT array, though they would appear in the next mainline execution of this section of code. (But put in the wrong place, of course)
This would not be the case with the "+" box because it's much slower in reporting data in the buffer. By the time it reports data in the buffer for the Axcess code to evaluate and parse, the entire string has had plenty of time to come in, even if it's a large string.
I believe if you change your code to look for end of the string instead of the beginning, your results will be as you desire.
In other words, change:
"ROOM_FIN_STR=FIND_STRING (ROOM_COM_BUF,$00,1) IF (ROOM_FIN_STR)"to
"ROOM_FIN_STR=FIND_STRING(ROOM_COM_BUF,$FF,1) IF (ROOM_FIN_STR)"or just
“IF(FIND_STRING(ROOM_COM_BUF,$FF,1)”Download: