public void set_mode(short new_mode) throws IOException {
      byte[] data=new byte[2];
      data[0]=(byte)SET_MODE;
      data[1]=(byte)new_mode;
      byte[] result = this.sendAndReceive(data, COM_TIMEOUT, 1);
      if (result.length==0) throw new IOException("no answer from device");
      if (result[0]!=0) throw new IOException("device error: "+result[0]);
      this.mode=new_mode;
    }