I'm trying to read the state of a old printer connected by RS232. In the manual of the printer I found the settings of the port: Baud 9600, 8 bit, 1 stop bit, No Parity, Flux Control Hardware. The printer accepts a text message and I send is something like: <MESSAGE> and for one label works fine.
The problem is the multiprint. If I make a for cycle for print multi messages, I should wait the machine is ready for next print. Still in the manual, I find that the printer uses the Xon-Xoff protocol. Now my cycle should wait for the char (DC1, 11 hex, 17 dec.) XOn for sending the next one message. I haven't find anything about how to read this value from the serial port. Any suggestions?
I have tried this code only for try to understand how I have to set the parameters, but I have one exception when I try to Open the serialport:
Dim ports As String() = SerialPort.GetPortNames()
Dim port As String
For Each port In ports
If port = "COM1" Then
' serialport1.BaudRate = 9600
' serialport1.DataBits = 8
' serialport1.Parity = Parity.None
' serialport1.StopBits = StopBits.One
' serialport1.Handshake = Handshake.XOnXOff
MessageBox.Show(port)
If SerialPort1.IsOpen = False Then SerialPort1.Open()
AddHandler SerialPort1.DataReceived, AddressOf DataReceivedHandler
End If
Next port