Never did any kind of embedded or hardware programming, I mainly deal with web applications. But we have the need to turn off / on a usb relay possibly in C#. I obtained a PDF of the device we are buying here.
In the document there is some sample code such as:
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);
}
Question is, wouldn’t I need a DLL / some sort of library to access serialPort1, sorry for the rubbish question but I’m just not certain how something like this works. I am not seeing any indication from the pdf or the website about any sort of library I would need to reference.
No, you just need to use the SerialPort class. As I recall the USB device will probably register itself as a serial port called ‘COM##’ where the hashes represent digits. You will need to supply the port name and the bit rate.