Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years, 1 month ago.
Send commands to mbed
Hello, mbed pros! I am new to mbed. I connect mbed to pc and want to transmit 7 bytes hexdecimal command to mbed and want to see feedback on pc. The seven bytes hex command is like this, FF 01 00 04 3F 00 44. I have no idea how to write the code. I will be grateful if anyone could give advice.
Best regards
2 Answers
12 years, 1 month ago.
As I said, just have a look at scanf, you probably can do it nicer with a loop, but it works:
#include "mbed.h" int main() { int buffer[7]; scanf("%2X %2X %2X %2X %2X %2X %2X", &buffer[0], &buffer[1], &buffer[2], &buffer[3], &buffer[4], &buffer[5], &buffer[6]); printf("received %d - %d - %d - %d - %d - %d - %d\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6]); }
I have finished the first step, using scanf and printf to input and show the hex commands on PC. My second step is to transmit command from pc through mbed to camera. Shall I combine the first code with "Pass through characters in both directions between the PC and Serial Port", which is shown in the serial communication with a pc?
posted by 20 Nov 201212 years, 1 month ago.
I dont know which way you know want to send stuff exactly, but have a look at the printf and scanf commands, especially while using %X