X13.Periphery.MsMessage.GetBytes C# (CSharp) Method

GetBytes() public method

public GetBytes ( ) : byte[]
return byte[]
    public virtual byte[] GetBytes() {
      if(_sendBuf==null) {
        if(_length>MSG_MAX_LENGTH) {
          throw new ArgumentOutOfRangeException(string.Format("Msg is too long {0}", this.ToString()));
        }

        if(_length>255) {
          _length+=2;
        }
        _sendBuf=new byte[_length];
        int ptr=0;
        if(_length>255) {
          _sendBuf[ptr++]=1;
          _sendBuf[ptr++]=(byte)(_length>>8);
          _sendBuf[ptr++]=(byte)(_length);
        } else {
          _sendBuf[ptr++]=(byte)(_length);
        }
        _sendBuf[ptr]=(byte)MsgTyp;

      }
      return _sendBuf;
    }

Usage Example

示例#1
0
 public void SendGw(MsDevice dev, MsMessage msg)
 {
     msg.GetBytes();
     lock (_sendQueue) {
         _sendQueue.Enqueue(msg);
     }
 }
All Usage Examples Of X13.Periphery.MsMessage::GetBytes