Exemplo n.º 1
0
        public static void WriteSerialNumber(ServerInfo info)
        {
            String output = JsonConvert.SerializeObject(info);

            byte[] buf = System.Text.Encoding.Default.GetBytes(output);
            MySerialPort.SendCommand(MT_RPC_CMD_SREQ | MT_RPC_SYS_SYS, MT_SYS_WRITE_SN, buf);
        }
Exemplo n.º 2
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (SerialPort_RxCnt > 0)
     {
         lock (Critical)
         {
             MySerialPort.InputMessage(SerialPort_ReadBuffer, SerialPort_RxCnt);
             SerialPort_RxCnt = 0;
         }
     }
 }
Exemplo n.º 3
0
 private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (MySerialPort.Port.IsOpen == true)
     {
         MySerialPort.Port.Close();
         MySerialPort.SaveParameter(comboBox2.Text, comboBox3.Text, comboBox5.Text, comboBox4.Text, comboBox6.Text);
         try
         {
             MySerialPort.Port.Open();
         }
         catch
         { Connect.Text = "连接"; MessageBox.Show("串口不存在或者被其他应用程序占用!", "提示"); }
     }
 }
Exemplo n.º 4
0
        public static void WriteSerialNumber(String psw, String url, String svr_ipv4, int svr_udp_port, int svr_tcp_port, int local_port)
        {
            ServerInfo info = new ServerInfo {
                password        = psw,
                server_url      = url,
                server_ipv4     = svr_ipv4,
                server_tcp_port = svr_tcp_port,
                server_udp_port = svr_udp_port,
                local_udp_port  = local_port
            };
            String output = JsonConvert.SerializeObject(info);

            byte[] buf = System.Text.Encoding.Default.GetBytes(output);
            MySerialPort.SendCommand(MT_RPC_CMD_SREQ | MT_RPC_SYS_SYS, MT_SYS_WRITE_SN, buf);
        }
Exemplo n.º 5
0
 private void Connect_Click(object sender, EventArgs e)
 {
     try
     {
         if (MySerialPort.Port.IsOpen == false)
         {
             MySerialPort.SaveParameter(comboBox2.Text, comboBox3.Text, comboBox5.Text, comboBox4.Text, comboBox6.Text);
             MySerialPort.Port.Open();
             Connect.Image = Properties.Resources.Close;
         }
         else
         {
             MySerialPort.Port.Close();
             Connect.Image = Properties.Resources.Open;
         }
     }
     catch
     { MessageBox.Show("串口不存在或者被其他应用程序占用!", "提示"); }
 }
Exemplo n.º 6
0
 public static void ReadSerialNumber(String psw)
 {
     MySerialPort.SendCommand(MT_RPC_CMD_SREQ | MT_RPC_SYS_SYS, MT_SYS_READ_SN, null);
 }
Exemplo n.º 7
0
 public static void ReadDeviceInfo()
 {
     MySerialPort.SendCommand(MT_RPC_CMD_SREQ | MT_RPC_SYS_SYS, MT_SYS_READ_INFO, null);
 }
Exemplo n.º 8
0
 public FactorySettings(Form1 form, System.IO.Ports.SerialPort sp)
 {
     myFom1             = form;
     mySerialPortObject = new MySerialPort(RecieveCommandListener, sp);
     MySerialPort.SetRecieveMessageListener(RecieveMessageListener);
 }