Guest User

Untitled

a guest
Jun 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. static void handle_cmd(volatile char* cmdLine)
  2. {
  3.  
  4. int i = 0;
  5.  
  6. volatile char* word[500] = {NULL, NULL, NULL};
  7. while((word[i] = parse_cmd_line(&cmdLine, ' ')) != NULL )
  8. {
  9. //printf("word[%i] = %sn", i, word[i]);
  10. i++;
  11. }
  12. //Analyse the 3 words :
  13. if(strcmp(word[0], "help") == 0)
  14. {
  15. print_usage();
  16. }
  17. else if(strcmp(word[0], "print") == 0)
  18. {
  19. printf("test print...n");
  20. }
  21. else if(strcmp(word[0], "temperature") == 0)
  22. {
  23. printf("temperature ");
  24. temperature_sensor();
  25. }
  26. else if(strcmp(word[0], "id") == 0)
  27. {
  28. serial_number();
  29. }
  30. /*else if(strcmp(word[0], "light") == 0)
  31. {
  32. light_sensor();
  33. }*/
  34.  
  35. else if(strcmp(word[0], "search") == 0)
  36. {
  37. //search_key(arg[1]);
  38. }
  39. else if(strcmp(word[0], "send") == 0)
  40. {
  41. if(strlen(word[1]) == 4)
  42. {
  43. printf("sending %s to %x", word[2], strtoul(word[1], NULL, 16));
  44. send_packet(strtoul(word[1], NULL, 16), word[2]);
  45. }
  46. }
  47.  
  48. else
  49. {
  50. printf("nCommand unknown !");
  51. }
  52. printf("command received : |%s|%s|%s|n", word[0], word[1], word[2]);
  53.  
  54. }
Add Comment
Please, Sign In to add comment