I don’t have time to check on it now, but you may be colliding with a predefined object named serial. Changing the name of the object to something more specific (e.g. my232port) can quickly determine if this is the issue; if you get the same error, that wasn’t it.
Looks like the problem is the data being transmitted. Loopback on RS-232 works fine. I am trying to read the ASCII put out by a Max Sonar but I am
guessing the syntax violates the VISA standard that the serial ports rely on so
the code crashes. I also tried the MXP port with the same results. (I did have a TTL-to-RS232 adapter when I tried the RS-232 port).
I had done a longer post this morning - not sure where it went.
Have you tried serial.reset()? I would suggest this immediately after the constructor.
You might also try manually calling serial.getBytesReceived() to see if it returns zero, an error, or something else.
Have you tried getting an error message from HALUtil? I’m not familiar with the HAL subsystem, and I was surprised to see it coming from a serial port; I suppose that the USB is somewhere behind the HAL system. The following should return a string that might prove enlightening: