Answer» I bought a Serial COMMUNICATION RELAY Control on ebay and am having issues compiling the C# code they supplied.
Code: [Select]private void button1_ON_Click(object sender, EventArgs e) { serialPort1.Write(new byte[] { 0xFF, 0x01,0x01},0,3); } private void button1_OFF_Click(object sender,EventArgs e ) { serialPort1.Write(new byte [] { 0xFF, 0x01,0x00},0,3); } When compiling it complains about 'serialPort1' is there a handler I am missing such as a .h include or?
This board can also be CONTROLLED via command line in a BATCH via setting up the mode for com3 9600,n,8,1,p and sending copy on.data com3 where the contents of on.data are passed to com3, but I have yet to send the correct input to the device. I see the communication handshaking with the led TX/RX, but am passing it the wrong info so it just sits there without latching the relay for 1 VS 0 bit.
Any suggestions ... btw the board was bought and shipped from Bulgaria and it appears it may become functional if I pass the correct string of data to the controller.
They also supply VB, but it also complains when compiling
Code: [Select]Private Sub cmdOff_Click() With MSComm1 'make sure the serial port is open If .PortOpen = False Then .PortOpen = True 'send the data .Output =Chr$(255) .Output =Chr$(1) .Output =Chr$(0) End With 'MSComm1 End Sub
Private Sub cmdOn_Click() With MSComm1 'make sure the serial port is open If .PortOpen = False Then .PortOpen = True 'send the data .Output =Chr$(255) .Output =Chr$(1) .Output =Chr$(1) End With 'MSComm1 End SubOk I found the solution. And got this to work in Batch... MS Windows XP decided that it knew the correct drivers for the USB/Serial Relay Driver Detected as a Virtual RS-232 Serial Device.
Got correct drivers from mfr and now its working by passing FF 01 01 to it to enable relay and FF 01 00 to disable relay at Com3
|