TX power control does not work

txPower

The only problem is that TX power control does not work.

The echo back comes back, but it contains only 6 bytes instead of 9 bytes. The remaining 3 bytes are received with the next read command, with which an “FB” response is expected.

txPower2

TX power control works fine with Flrig, and if I change the subcommand from “0A” to “09” or “0B”, the echo back is OK.

txPower3

Because “0x0a” is a Line Feed character, or a New Line, and has a meaning of End Of Line (EOL) by default, some care might be required.

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);
}

I thought setting a VEOL character overrides the existing EOL character, 0x0a, but it seems not. There should be some way to treat 0x0a as a normal character, but in the meanwhile, here is a dirty hack.

 n_echoback = read(fd, echoback, 255); /* get echo back */
 if(echoback[n_echoback-1] == 0x0a) {  /* if it ends with "0x0a" */
  n_echoback2 = read(fd, echoback2, 255); /* get the rest */
  for(int i=0;i<n_echoback2;i++) {
   echoback[n_echoback+i]=echoback2[i];   /* and append */
  }
  n_echoback += n_echoback2;
 }

Leave a Reply

Your email address will not be published. Required fields are marked *