Originally I made a POS application using Excel/VB. Everything worked A-OK, especially the serial communication with the POS display pole. Here's an example of the code by which I had the application communicate:
Function Send2Display(ln1$, Optional ln2$)
On Error GoTo theEnd
Dim ln1Space As Byte, ln2Space As Byte
ln1 = Left(ln1, 20): ln1Space = 20 - Len(ln1)
ln2 = Left(ln2, 20): ln2Space = 20 - Len(ln2)
Open "COM1:" For Output As #1
' Write lines and then set cursor to start
Print #1, ln1; Spc(ln1Space); ln2; Spc(ln2Space)
Print #1, Chr$(&H1B)
theEnd:
Err.Clear: Close #1
End Function
As I said, this worked ok. Now however I've moved the POS application over to RoR and I've had to make a Java applet for the purpose of communicating with the display pole. The applet works fine save for the following problem:
I'm not sure what the cause of it is, but at a given point in time Java reports that I'm using "an incorrect||missing function" when sending data to the COM port. I have to close the application (web page), then disable COM1 in the Device Manager then re-enable it. Then when I load the web page again it starts working. See this page for the Java code and JNLP.
If the COM port is unresponsive to the web app I can load the old Excel file and it will still work. I'm at a loss as to why it won't work for the Java applet.