process_socket_commands.py is the first Python script to be run.
For completeness these files are distributed in the following links:
http://letsmakerobots.com/blog/unixguru ... t-part-1-3
http://letsmakerobots.com/blog/unixguru ... t-part-2-3
http://letsmakerobots.com/blog/unixguru ... t-part-3-3
I have been unable to contact the author for comment or suggestions.
The 3 file attachment limit prevents me from uploading the Arduino sketch but here is the relevant code for parsing the I2C data received by the Arduino:
Code: Select all
// Take the Comma separated I2C string and format it to Command and Parameter
void ParseI2CData()
{
char *p = I2CinBuffer; // The data to be parsed
char *str; // Temp store for each data chunk
int count = 0; // Id ref for each chunk
while ((str = strtok_r(p, ",", &p)) != NULL) // seperate at each "," delimiter
{
inParse[count] = str; // Add chunk to array
count++;
}
//Serial.print(I2CinBuffer);
//Serial.print(" ");
//Serial.println(count);
//Serial.print('line 170');
if(count == 2) // If the data has two values then..
{
Command = inParse[0]; // Define value 1 as a Command identifier
//Serial.print("Command from I2C in is.... ");
//Serial.println(Command);
Parameter = inParse[1]; // Define value 2 as a Parameter value
//Serial.print("Parameter from I2C in is.... ");
//Serial.println(Parameter);
processCommand();
}
}