Exemple #1
0
 public unsafe int write(DeviceHandle handle, DataBuffer data)
 {
     byte* numPtr = stackalloc byte[0x100];
     if (handle.isInvalid())
     {
         GlobalServices.ErrMsg("DDI_EZLinkDongle.write()", "called with INVALID handle");
         return -1;
     }
     Protocol protocol2 = data.ddi_getProtocol();
     if (protocol2 == Protocol.Write)
     {
         string str;
         data.ddi_getCommand_Transmit(out str);
         numPtr[0] = (byte) (str.Length + 4);
         numPtr[1] = 170;
         numPtr[2] = 0x2d;
         numPtr[3] = 0xd4;
         numPtr[4] = (byte) str.Length;
         for (int i = 0; i < str.Length; i++)
         {
             numPtr[i + 5] = (byte) str[i];
         }
         this._ddi_EZLinkDLL_State = DDI_EZLinkDLL_State.EZLink_Transmit_Start;
         this._ddi_EZLinkDLL_State = DDI_EZLinkDLL_State.EZLink_Transmit_End;
     }
     else if (protocol2 == Protocol.WriteRegister)
     {
         uint num;
         uint num2;
         data.ddi_getCommand_WriteRegister(out num, out num2);
         this._ddi_EZLinkDLL_State = DDI_EZLinkDLL_State.EZLinkReg_Write_Start;
         this._ddi_EZLinkDLL_State = DDI_EZLinkDLL_State.EZLinkReg_Write_End;
     }
     else
     {
         GlobalServices.ErrMsg("DDI_EZLinkDongle.write()", "Unexpected protocol received");
     }
     return 0;
 }