Mateusz Jaskula
/
KL25Z_TangoIO
KL25 driver for Tango Control System
Diff: main.cpp
- Revision:
- 1:f1ee978773d3
- Parent:
- 0:5d27c333afa6
- Child:
- 2:9fe6f1e273b4
--- a/main.cpp Mon Aug 25 12:00:15 2014 +0000 +++ b/main.cpp Tue Aug 26 06:46:55 2014 +0000 @@ -120,13 +120,13 @@ pc.printf("\n \r %s \n \r", command); // send received command to pc (DEBUG) if(strcmp(command,"read_sensor")==0) { // data read from sensor - sprintf(command, "Sensor data: %10f,%10f,%10f,%10f,%10f,%10f,%10f,%10f,%10f, %10f", magn[0], magn[1], magn[2], accel[0], accel[1], accel[2], gyro[0], gyro[1], gyro[2], TSI_pos); // enter data to buffer + sprintf(command, "{""magnX"":%10f,""magnY"":%10f,""magnZ"":%10f,""accelX"":%10f,""accelY"":%10f,""accelZ"":%10f,""gyroX"":%10f,""gyroY"":%10f,""gyroZ"":%10f,""TSIpos"":%10f}", magn[0], magn[1], magn[2], accel[0], accel[1], accel[2], gyro[0], gyro[1], gyro[2], TSI_pos); // enter data to buffer wait(0.001); // wait - pc.printf("\n \r sending sensor data!"); // pc info (debug) + pc.printf("\n \r sending sensor data! %s", command); // pc info (debug) } else if (strcmp(command,"check_ports")==0) { // check I/O ports current values - sprintf(command, "Ports values: P1: %d, P2: %d, P3: %d, P4: %d, P5: %d, P6: %d", P1.read(), P2.read(), P3.read(), P4.read(), P5.read(), P6.read()); + sprintf(command, "{""P1"":%d,""P2"":%d,""P3"":%d,""P4"":%d,""P5"":%d,""P6"":%d}", P1.read(), P2.read(), P3.read(), P4.read(), P5.read(), P6.read()); } else if (strcmp(command,"get_P1")==0) { // get P1 value - sprintf(command, "P1 value: %d", P1.read()); // + sprintf(command, "{P1:%d}", P1.read()); // } else if(strcmp(command,"set_P1_o")==0) { // set P1 as output P1.output(); // sprintf(command, "P1 is now set as output"); // @@ -136,11 +136,11 @@ } else if (strcmp(command,"set_P1_1")==0) { // set P1 as 1 P1.output(); // set to output P1.write(1); // write 1 to P1 - sprintf(command, "P1 value is now: %d ", P1.read()); // reply with current value to check + sprintf(command, "{P1:%d}", P1.read()); // reply with current value to check } else if (strcmp(command,"set_P1_0")==0) { // set P1 as 0 P1.output(); // P1.write(0); - sprintf(command, "P1 value is now: %d ", P1.read()); + sprintf(command, "{P1:%d}", P1.read()); } else if (strcmp(command,"get_P2")==0) { sprintf(command, "P2 value: %d", P2.read()); } else if (strcmp(command,"set_P2_o")==0) {