данная программа при запуске ловит нажатие клавиш, и посылает на COM порт соответствующие команды.

#include <stdio.h> #include <termios.h> #include <unistd.h> int ch; int mychar( ) { struct termios oldt, newt; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag &= ~( ICANON | ECHO ); tcsetattr( STDIN_FILENO, TCSANOW, &newt ); ch = getchar(); tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); return ch; } int main() { while(1) { mychar(); switch (ch) { case 87: case 119: system("echo 'F' >/dev/ttyACM1"); printf("Forward\n"); break; case 83: case 115: system("echo 'S' >/dev/ttyACM1"); printf("Stop\n"); break; case 65: case 97: system("echo 'L' >/dev/ttyACM1"); printf("Left\n"); break; case 68: case 100: system("echo 'R' >/dev/ttyACM1"); printf("Right\n"); break; case 81: case 113: system("echo 'A' >/dev/ttyACM1"); printf("Leftforward\n"); break; case 66: case 98: system("echo 'B' >/dev/ttyACM1"); printf("Back\n"); break; case 69: case 101: system("echo 'C' >/dev/ttyACM1"); printf("Rightforward\n"); break; case 61: system("echo 'D' >/dev/ttyACM1"); printf("LeftUpspeed\n"); break; case 45: system("echo 'E' >/dev/ttyACM1"); printf("LeftDownspeed\n"); break; case 48: system("echo 'K' >/dev/ttyACM1"); printf("RightUpspeed\n"); break; case 57: system("echo 'M' >/dev/ttyACM1"); printf("RightDownspeed\n"); break; case 82: case 114: system("echo 'I' >/dev/ttyACM1"); printf("Rootstart\n"); break; case 84: case 116: system("echo 'J' >/dev/ttyACM1"); printf("Rootend\n"); break; case 108: case 76: system("echo 'O' >/dev/ttyACM1"); printf("RightPlatform\n"); break; case 106: case 74: system("echo 'T' >/dev/ttyACM1"); printf("leftPlatform\n"); break; case 105: case 73: system("echo 'P' >/dev/ttyACM1"); printf("UpPlatform\n"); break; case 107: case 75: system("echo 'Q' >/dev/ttyACM1"); printf("DownPlatform\n"); break; case 109: case 77: system("echo 'U' >/dev/ttyACM1"); printf ("DefPosWebCam"); } } }

описание программы передачи управляющих команд на контроллер платформы