kevlar129bp
- 1st December 2010, 04:57
Hey guys,
As you've gathered from my "parts sourcing" post, I am in the heat of the battle on my "code sniffer" project. I thought I had the code to check for valid digits licked but then...doh!
EEAddress=414
I2CREAD I2cData,I2cClock,$A0,EEAddress,[CheckPanelDigit]
IF CheckPanelDigit < 153 THEN
EEAddress=415
I2CREAD DPIN,CPIN,$A0,EEAddress,[CheckPanelDigit]
IF CheckPanelDigit < 153 THEN 'BETWEEN HEX 00 AND 99
Goto ConcordExpress
else
goto SnifferErr
endif
else
goto SnifferErr
endif
As I am checking for "valid" digits, I figured I could just make sure they are below DEC 153 (Hex 99). Well, what if I happen to get a "8E" (DEC 142)? The code will execute, which I can't allow to happen. I guess the easiest way to explain it is: the hex received must have 2 valid digits in it, 0-9.
Is there a routine, or a bit of math trickery I can perform to do the verification of the hex pair?
Whew, I think I confused myself after reading this post! :confused:
I hope it makes sense to one of you.
Thanks guys,
Chris
As you've gathered from my "parts sourcing" post, I am in the heat of the battle on my "code sniffer" project. I thought I had the code to check for valid digits licked but then...doh!
EEAddress=414
I2CREAD I2cData,I2cClock,$A0,EEAddress,[CheckPanelDigit]
IF CheckPanelDigit < 153 THEN
EEAddress=415
I2CREAD DPIN,CPIN,$A0,EEAddress,[CheckPanelDigit]
IF CheckPanelDigit < 153 THEN 'BETWEEN HEX 00 AND 99
Goto ConcordExpress
else
goto SnifferErr
endif
else
goto SnifferErr
endif
As I am checking for "valid" digits, I figured I could just make sure they are below DEC 153 (Hex 99). Well, what if I happen to get a "8E" (DEC 142)? The code will execute, which I can't allow to happen. I guess the easiest way to explain it is: the hex received must have 2 valid digits in it, 0-9.
Is there a routine, or a bit of math trickery I can perform to do the verification of the hex pair?
Whew, I think I confused myself after reading this post! :confused:
I hope it makes sense to one of you.
Thanks guys,
Chris