Delcom DLL Manual - Delcom Products Inc.
Delcom DLL Manual - Delcom Products Inc.
Delcom DLL Manual - Delcom Products Inc.
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
8.0 Sample Code8.1 Send and Read Data Packet// <strong>Delcom</strong><strong>DLL</strong>ExampleC#include "stdafx.h"#include "<strong>Delcom</strong><strong>DLL</strong>.h"int main(int argc, char* argv[]){PacketStruct Packet;char DeviceName[MaxDeviceLen];if(!<strong>Delcom</strong>GetNthDevice(USBIODS, 0, DeviceName)) return(0);HANDLE hUsb = <strong>Delcom</strong>OpenDevice((char*)DeviceName,0);// Write PacketPacket.Recipient = 8; // always 8Packet.DeviceModel = 18; // always 18Packet.MajorCmd = 10;Packet.MinorCmd = 10; // write port0 & port1Packet.DataLSB = 0xFF; // set port0 to all highPacket.DataMSB = 0x00; // set port1 to all lowPacket.Length = 0;// DataExt not used<strong>Delcom</strong>SendPacket(hUsb,&Packet,NULL);// Write Packet with Data ExtPacket.Recipient = 8; // always 8Packet.DeviceModel = 18; // always 18Packet.MajorCmd = 10;Packet.MinorCmd = 60; // write port0 & port1Packet.DataLSB = 0xFF; // set port0 to all highPacket.DataMSB = 0x00; // set port1 to all lowPacket.Length = 3;// DataExt used, sending 3 bytesPacket.ExtData[0] = 1;Packet.ExtData[1] = 2;Packet.ExtData[2] = 3;<strong>Delcom</strong>SendPacket(hUsb,&Packet,NULL);// Read PacketPacket.Recipient = 8; // always 8Packet.DeviceModel = 18; // always 18Packet.MajorCmd = 11;Packet.MinorCmd = 0;// read port0 & port1Packet.Length = 0;// DataExt not used<strong>Delcom</strong>SendPacket(hUsb,&Packet,&Packet);printf("Port0=%X Port1=%X\n",((char*)&Packet)[0],((char*)&Packet)[1]);<strong>Delcom</strong>CloseDevice(hUsb);// close the device}return(0);<strong>Delcom</strong> <strong>DLL</strong> <strong>Manual</strong> 20 of 21 June 9, 2011 Ver 1.1