void send_command(const char *command) { char tx_buf[32]; #ifdef ALLEGRO_WINDOWS DWORD bytes_written; #endif sprintf(tx_buf, "%s\r", command); // Append CR to the command #ifdef ALLEGRO_WINDOWS PurgeComm(com_port, PURGE_TXCLEAR|PURGE_RXCLEAR); WriteFile(com_port, tx_buf, strlen(tx_buf), &bytes_written, 0); if (bytes_written != strlen(tx_buf)) { #ifdef LOG_COMMS log_comm("TX ERROR", tx_buf); // Log transmission error #endif return; } #else comm_port_flush_output(com_port); comm_port_flush_input(com_port); comm_port_string_send(com_port, tx_buf); #endif #ifdef LOG_COMMS write_comm_log("TX", tx_buf); #endif }
void send_command(const char *command) { char tx_buf[32]; #ifdef ALLEGRO_WINDOWS DWORD bytes_written; #endif sprintf(tx_buf, "%s\r", command); // Append CR to the command #ifdef ALLEGRO_WINDOWS PurgeComm(com_port, PURGE_TXCLEAR|PURGE_RXCLEAR); WriteFile(com_port, tx_buf, strlen(tx_buf), &bytes_written, 0); if (bytes_written != strlen(tx_buf)) { #ifdef LOG_COMMS log_comm("TX ERROR", tx_buf); // Log transmission error #endif return; } #elif TERMIOS // printf("tx:'%s'\n",command); if( write(fdtty,tx_buf,strlen(tx_buf)) == -1 ) { perror("write tty"); close(fdtty); fdtty = -1; } else { tcflush(fdtty, TCIFLUSH); } #else comm_port_flush_output(com_port); comm_port_flush_input(com_port); comm_port_string_send(com_port, tx_buf); #endif #ifdef LOG_COMMS write_comm_log("TX", tx_buf); #endif }
void send_command(const char *command) { char tx_buf[32]; sprintf(tx_buf, "%s\r", command); // Append CR to the command #ifdef LOG_COMMS write_comm_log("TX", tx_buf); #endif #ifdef ALLEGRO_WINDOWS DWORD bytes_written; PurgeComm(com_port, PURGE_TXCLEAR|PURGE_RXCLEAR); WriteFile(com_port, tx_buf, strlen(tx_buf), &bytes_written, 0); #else comm_port_flush_output(com_port); comm_port_flush_input(com_port); comm_port_string_send(com_port, tx_buf); #endif }