X13.Periphery.MsDevice.MsGSerial.SendRaw C# (CSharp) Méthode

SendRaw() private static méthode

private static SendRaw ( MsGSerial g, MsMessage msg, byte tmp ) : void
g MsGSerial
msg MsMessage
tmp byte
Résultat void
      private static void SendRaw(MsGSerial g, MsMessage msg, byte[] tmp) {
        if(g==null || g._port==null || !g._port.IsOpen || msg==null) {
          return;
        }
        byte[] buf=msg.GetBytes();
        int i, j=0;
        byte b;
        b=(byte)buf.Length;
#if UART_RAW_MQTTSN
        tmp[j++]=b;
        for(i=0; i<buf.Length; i++) {
          tmp[j++]=buf[i];
        }
#else
        tmp[j++]=0xC0;
        if(b==0xC0 || b==0xDB) {
          tmp[j++]=0xDB;
          tmp[j++]=(byte)(b ^ 0x20);
        } else {
          tmp[j++]=b;
        }
        for(i=0; i<buf.Length; i++) {
          if(buf[i]==0xC0 || buf[i]==0xDB) {
            tmp[j++]=0xDB;
            tmp[j++]=(byte)(buf[i] ^ 0x20);
          } else {
            tmp[j++]=buf[i];
          }
        }
        tmp[j++]=0xC0;
#endif
        g._port.Write(tmp, 0, j);

        if(_verbose.value) {
          Log.Debug("s {0}: {1}  {2}", g._port.PortName, BitConverter.ToString(buf), msg.ToString());
        }
      }
      #endregion static

Same methods

MsDevice.MsGSerial::SendRaw ( SerialPort port, byte buf, byte tmp ) : void