/// <summary> /// Writes the ports values /// returns zero on sucess, else non-zero erro /// </summary> public UInt32 WritePorts(UInt32 Port0, UInt32 Port1) { try { myTxHidPacket.MajorCmd = 101; myTxHidPacket.MinorCmd = 10; myTxHidPacket.LSBData = Convert.ToByte(Port0); myTxHidPacket.MSBData = Convert.ToByte(Port1); if (Hid.HidD_SetFeature(myDeviceHandle, StructureToByteArray(myTxHidPacket), 8) == false) { return(1); } else { return(0); } } catch (Exception ex) { DisplayException(MODULE_NAME, ex); //throw; return(2); } }
/// <summary> /// Setups up the ports /// SetupPort( Port#, Initvalue, Input/Output, Pullups, Interrupts /// </summary> public UInt32 SetupPort(UInt32 PortNum, UInt32 InitValue, UInt32 Direction, UInt32 Pullups, UInt32 Interrutps) { try { myTxHidPacket.MajorCmd = 101; myTxHidPacket.MinorCmd = 130; myTxHidPacket.LSBData = Convert.ToByte(PortNum); myTxHidPacket.HidData0 = Convert.ToByte(InitValue); myTxHidPacket.HidData1 = Convert.ToByte(Direction); myTxHidPacket.HidData2 = Convert.ToByte(Pullups); myTxHidPacket.HidData3 = Convert.ToByte(Interrutps); if (Hid.HidD_SetFeature(myDeviceHandle, StructureToByteArray(myTxHidPacket), 8) == false) { return(1); } else { return(0); } } catch (Exception ex) { DisplayException(MODULE_NAME, ex); //throw; return(2); } }
/// <summary> /// Writes the ports values /// returns zero on sucess, else non-zero erro /// </summary> public UInt32 SendCommand(HidTxPacketStruct TxCmd) { try { int Length; if (TxCmd.MajorCmd == 102) { Length = 16; } else { Length = 8; } if (Hid.HidD_SetFeature(myDeviceHandle, StructureToByteArray(TxCmd), Length) == false) { return(1); } else { return(0); } } catch (Exception ex) { DisplayException(MODULE_NAME, ex); //throw; return(2); } }