I am using a simple matlab code to send serial data to a COM port device, however I am having issues and would like an equivalent C/C++ code to achieve the same result. Shown below is the MATLAB code.
s_port = serialport('COM1',9600);
configureTerminator(s_port,'CR');
write(s_port,char([50 01]),"char");
pause(1)
write(s_port,char([16 2 150]),"char")
write(s_port,char([55 18]),"char")
write(s_port,char(54),"char");
I attempted to use MATLAB coder, but I don't think there is a stock equivalent to matlab's serialwrite function.
Thanks