Does not end with 0x00

dataFormat

Because the ICOM commands end with 0xfd and may include 0x00, they are not null-terminated strings, and some special routines are required to get their length, etc.

#define END_OF_COMMAND 0xfd

int mystrlen(unsigned char* string) {
 unsigned char* t;
 for(t = string; *t != END_OF_COMMAND; t++) {
  ;
 }
 return (t - string) + 1; /* +1 to include EOC */
}

int mystrcmp(unsigned char* string1, unsigned char* string2) {
 unsigned char* t1;
 unsigned char* t2;

 for(t1 = string1, t2 = string2; *t1 == *t2 && *t1 != END_OF_COMMAND; t1++, t2++) { 
  ;
 }
 return *t1 - *t2;
}

If you send a command to IC-7410, it always echos back the command received. I was just skipping the echo, but it might be a good idea to check if the command is received alright.

gboolean send_command(unsigned char* command){
 int n_send, n_receive; 
 unsigned char echo_back[256];

 n_send = mystrlen(command);
 write(fd, command, n_send);
 n_receive = read(fd,echo_back,255);

 if ( (n_receive != n_send) || (mystrcmp(command, echo_back) != 0) ) {
  return FALSE;
 } else {
  return TRUE;
 }
}