We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I am using processing to communicate via serial with a fingerprint sensor (GT-511C3) and the messages it sends looks something like this: 55-AA-01-00-0F-10-00-00-31-00-50-01.
as these are sent separately and constantly I cannot in this state listen for a specific byte changing (e.g. the 0F changing to 00) so I would like to convert these sets of bytes to ints so that I can use them to trigger specific events.
Any idea of how I would go about to do that would be much appreciated.
here is the code Im using to receive them:
void serialEvent(Serial p) { byte rx_byte;
while (p.available() > 0) { // get a single character from the serial port rx_byte = (byte)serial_port.readChar(); println(hex(rx_byte)); } }
Thanks!
Answers
I'm not sure I understand your question. A
byte
is a subset ofint
. If you have abyte
, you can just treat it as anint
. This works fine:Is there something else you're trying to do? Can you post a small example with hardcoded values (and code tags) like mine (get rid of the serial stuff) that shows where you're stuck?
Thanks for the answer, Maybe I didn't explain myself very well. Im pretty new to processing so maybe my question is not the correct one for my problem.
I am sending messages via serial to a sensor and the sensor answers by sending back YES or NO represented by a set of twelve bytes, but since they come continuously I do not know how I can interpret them as Yes/no. so I was thinking that if I could take the 12 bytes and convert them to one int I could use that to trigger functions.
Another approach could maybe be to only listen to some of the bytes (say byte number 6 out of the 12) and ignore rest but I would then still need some way of grouping the sets of bytes to separate them out from each other.
I can unfortunately not show you much code that would be useful as this part of the functionality is not there.
Thanks again!
PDF link http://cdn.sparkfun.com/datasheets/Sensors/Biometric/GT-511C3_datasheet_V1 1_20130411[4].pdf
page 6 has the format of the response
55|AA|01-00|0F-10-00-00|31-00|50-01
Thanks!