Beispiel #1
0
 private void OnCommandSend(CommandData sender, byte value)
 {
     if (_serial.IsOpen)
     {
         _serial.Write(new byte[] { value });
     }
 }
Beispiel #2
0
    private void CommandCodeStar(CMD cmd, int param)
    {
        byte data = (byte)((int)cmd << 4);

        data += (byte)(param & 0x0f);
        codeStarComm.Write(new byte[] { data });
    }
Beispiel #3
0
    void TestComm()
    {
        byte[] packet = new byte[10];
        packet[0] = 0xff;         // header1
        packet[1] = 0xff;         // header2
        packet[2] = 0xfd;         // header3
        packet[3] = 0x00;         // reserved
        packet[4] = 0xc8;         // id (200)
        packet[5] = 0x03;         // length0
        packet[6] = 0x00;         // length1
        packet[7] = 0x01;         // instruction
        ushort crc = update_crc(0, ref packet);

        packet[8] = (byte)(crc & 0xFF);         // crc0
        packet[9] = (byte)((crc >> 8) & 0xFF);  // crc1

        /*
         * byte[] packet = new byte[13];
         * packet[0] = 0xff; // header1
         * packet[1] = 0xff; // header2
         * packet[2] = 0xfd; // header3
         * packet[3] = 0x00; // reserved
         * packet[4] = 0xc8; // id (200)
         * packet[5] = 0x06; // length0
         * packet[6] = 0x00; // length1
         * packet[7] = 0x03; // instruction (Write)
         * packet[8] = 0x15; // address0 (Set Mode)
         * packet[9] = 0x00; // address1
         * packet[10] = 0x04; // data (BYTE)
         * ushort crc = update_crc(0, ref packet);
         * packet[11] = (byte)(crc & 0xFF); // crc0
         * packet[12] = (byte)((crc >> 8) & 0xFF); // crc1
         */

        serial.Write(packet);

        Debug.Log("TestComm");
    }