RS-232 Incoming Comparison

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

RS-232 Incoming Comparison

Post by Widgetman » Tue Jan 01, 2008 3:35 pm

Hi,
I was wondering if someone could give me a simple example of how to compare incoming bytes from the USART to constant values stored in memory. I am trying to verify a response from a unit I am talking to over the RS-232 port. Any thoughts or help would be greatly appreciated.
Thanks

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Tue Jan 01, 2008 3:49 pm

Hello wigetman, this is how I would do it:-

Code: Select all

dim result as boolean
dim temp_byte as byte

result=false
temp_byte=EEPROM_value    'you will have to figure out how to read the value out of the EEPROM

result=USART.WaitForTimeout(temp_byte,1000)  'look for return byte value and timeout(1000ms) if failed, result is true if value matches
If result=true Then
      'do something

else
     'do something else

endif
Look at the USART module for details of the "waitfor" commands, there is also a string version.

Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

Post by Widgetman » Tue Jan 01, 2008 8:54 pm

Hi Doj,
Thanks a bunch. The more I play with this compiler the more I am falling in love. it is so much easier to use than those C compilers out there.
I will play with your example.

Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

Post by Widgetman » Tue Jan 01, 2008 8:54 pm

Hi Doj,
Thanks a bunch. The more I play with this compiler the more I am falling in love. it is so much easier to use than those C compilers out there.
I will play with your example.
8)

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Wed Jan 02, 2008 1:25 am

let us know how you get on, physically manipulating the ram elements with the end of a pin is easier than using C, in my opinion!

Post Reply