system
April 12, 2012, 7:43pm
1
Hello, I am using some sample code from a website and they have some code that I am unfamiliar with. It's pretty simple code, I just don't know it.
char command_scantag[]={0x31,0x03,0x01};
Could someone please explain what this means to me? I know the variable is initiated as a character string and the stuff inside the curly brackets are what is being put into the character string. If you could tell me what the syntax they are using is called, for instance whether it's hexadecimal code and why there are 3 different portions. Really just an all encompassing explanation.
Thanks
system
April 12, 2012, 7:46pm
2
I can figure the '1' in the first position, but without knowing the context, the last two control characters are a mystery.
system
April 12, 2012, 7:48pm
3
I'm not sure what you need, so this is all the code.
/*
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
// include the library code:
#include <LiquidCrystal.h>
#define BUFFSIZ 90
//RFID parser
char buffer_RFID[BUFFSIZ];
char buffidx_RFID;
char response_str[64];
char command_scantag[]={0x31,0x03,0x01};//const
unsigned char incomingByte;
unsigned char parsed_okay=0;
unsigned char tag_found_number;
unsigned int bytecount=0;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(){
parsed_okay=0;
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Xbee UHFRFID Reader");
Serial.begin(9600);
Serial1.begin(115200);
Serial.println("Test Xbee Connection");
}
void loop()
{
while(Serial.available())
{
incomingByte = Serial.read();
if(incomingByte='r') {
Serial1.print(command_scantag);
parsed_okay=0;
}
}
while(Serial1.available())
{
incomingByte = Serial1.read();
Serial.print(incomingByte);
if(incomingByte==0x32 && parsed_okay==0) {
bytecount=0;
parsed_okay=1;
}
bytecount++;
if(bytecount==3) {
lcd.clear();
lcd.print(incomingByte, DEC);
}
}
}
system
April 12, 2012, 7:51pm
4
char command_scantag[]={0x31,0x03,0x01};
the [] indicates that command_scantag is an array.
0x designates hexidecimal so the three values put into the array
are 31 hex, 03 hex, and 01 hex respectively
system
April 16, 2012, 1:37am
5
why is it '1' out of context and 49, 3, 1 in context?
system
April 16, 2012, 9:32am
6
why is it '1' out of context and 49, 3, 1 in context?
At the risk of being redundant, this question needs some context.