Esempio n. 1
0
 //Input events
 public void SendMessage(object sender, EventArgsLibrary.MessageEncodedArgs e)
 {
     if (IsSerialPortConnected)
     {
         try
         {
             //Quand on reçoit un message à envoyer, on le fait partir
             Write(e.Msg, 0, e.Msg.Length);
         }
         catch
         {
             //Si pb de connexion
             IsSerialPortConnected = false;
             //On relance la procédure de connexion
             StartTryingToConnect();
         }
     }
 }
Esempio n. 2
0
 //Input events
 public void SendUSBMessage(object sender, EventArgsLibrary.MessageEncodedArgs e)
 {
     if (_deviceDetected && _deviceReady)
     {
         UInt32  LengthTransferred = 0;
         Boolean success           = false;
         if (e.Msg.Length <= 128 && cmv8DeviceListeFound.Count > 0)
         {
             RequestToSendDataViaBulkTransfer(cmv8DeviceListeFound[0], (uint)e.Msg.Length, e.Msg, ref LengthTransferred, ref success);
         }
         else
         {
             Int32 bytesToSend = e.Msg.Length;
             while (bytesToSend > 0)
             {
                 /**/ RequestToSendDataViaBulkTransfer(cmv8DeviceListeFound[0], (uint)e.Msg.Length, e.Msg, ref LengthTransferred, ref success);
                 bytesToSend -= (Int32)LengthTransferred;
             }
         }
     }
 }
 //Input events
 public void SendMessage(object sender, EventArgsLibrary.MessageEncodedArgs e)
 {
     if (IsSerialPortConnected)
     {
         try
         {
             //Quand on reçoit un message à envoyer, on le fait partir
             Write(e.Msg, 0, e.Msg.Length);
             //Console.WriteLine("Message sent:" + DateTime.Now.Millisecond.ToString());
         }
         catch
         {
             //Si pb de connexion
             IsSerialPortConnected = false;
             //On relance la procédure de connexion si on a n'a pas de demande de fermeture en cours
             if (!isRequiredToBeClosed)
             {
                 StartTryingToConnect();
             }
         }
     }
 }