Now the callback function is modified to include the lines for sending a command that relates to the button clicked.
void callback( GtkWidget *widget, gpointer data ) { static char output[128]; int outputcount; static char command_cw [7] = {0xfe, 0xfe, 0x80, 0xe0, 0x06, 0x03, 0xfd}; /* set mode to CW */ static char command_cw-rev[7] = {0xfe, 0xfe, 0x80, 0xe0, 0x06, 0x07, 0xfd}; /* set mode to CW-REV */ if(g_strcmp0((char *) data, "CW") == 0) { outputcount = 7; /* command length */ write(fd, &command_cw, outputcount); } if(g_strcmp0((char *) data, "CW-REV") == 0) { outputcount = 7; /* command length */ write(fd, &command_cw-rev, outputcount); } }
The above code is not complete, but you can see what I am trying to do.
#define MYRIG "/dev/ttyUSB0" #define BAUDRATE B19200 void serial_init(void) { struct termios tio; memset(&tio, 0, sizeof(tio)); tio.c_cflag = CS8 | CLOCAL | CREAD; tio.c_cc[VTIME] = 0; tio.c_cc[VEOL ] = 0xfd; /* IC-7410 postamble */ tio.c_lflag = ICANON; tio.c_iflag = IGNPAR | ICRNL; cfsetispeed(&tio, BAUDRATE); cfsetospeed(&tio, BAUDRATE); tcsetattr (fd, TCSANOW, &tio); } /* main() */ fd = open(MYRIG, O_RDWR | O_NOCTTY); serial_init();
You also need to add the above lines before talking to IC-7410. Lines for error check are omitted for clarity. See CW Keyboard (2) for an complete example.
Some scale widgets are added.