Ejemplo n.º 1
0
        private void timer_Tick(object sender, EventArgs e)
        {
            // 先頭1バイトに0x01を入れてパケットを送信
            device.Send(0x01);
            // デバイスからパケットを受信
            byte[] res = device.Receive();
            if (res[0] == 0)
            {
                textBoxSwitch.Text = "OFF";
            }
            else
            {
                textBoxSwitch.Text = "ON";
            }

            // 先頭1バイトに0x02を入れてパケットを送信
            device.Send(0x02);
            // デバイスからパケットを受信
            res = device.Receive();
            uint value = (uint)res[0] * 256 + res[1];

            textBoxADC.Text = value.ToString();
        }
        private void timer_Tick(object sender, EventArgs e)
        {
            // Send packet by putting 0x01 in the first byte
            device.Send(0x01);
            // Receive packet from device
            byte[] res = device.Receive();
            if (res[0] == 0)
            {
                textBoxSwitch.Text = "OFF";
            }
            else
            {
                textBoxSwitch.Text = "ON";
            }

            // Send packet by putting 0x02 in the first byte
            device.Send(0x02);
            // Receive packet from device
            res = device.Receive();
            uint value = (uint)res[0] * 256 + res[1];

            textBoxADC.Text = value.ToString();
        }