Hi there. Using Gambas 3.8.4 from PPA on Ubuntu 14.04 x64. I'm having issues with serial ports. I have a USB to 4 RS232C hub adapter. It is working on a virtual Windows machine, reading and writing as it is supposed to do. The connected device (using one port only) is a Magnetic Card Encoder that uses binary data (i.e: not always printable ASCII) to be told what to do. Using the mobo's built-in RS232 port as well as a PCIe 4xRS232 card yield the same results, so the ports do not seem to be at fault here.
My program tries to guess if the encoder is present at the specified port by sending the byte sequence 0x02-0xF8-0x31-0x03, which is an invalid command for the device. The device should respond with 0x02-0x15-0x03. All data comm blocks are surrounded by STX (0x02) and ETX (0x03) bytes. The problems I am having are two: 1- I can't have Gambas trigger the READ event for the port, thus I call it by hand. 2- I can't figure out how to get the data from the encoder into a string without missing bytes. My code is encapsulated in a class. Declarations: Instancing and setting the port up: Then, I send TEST_TX and expect for either TEST_RX or a timeout: Finally, this next is the problem code. It does not fire as expected when data arrives, and when I call it by hand in the IF above, if I try to READ #m_tty As String it chops off the leading 0x02 byte, and I could not figure out how to READ #m_tty As Byte[] or As Object (I get a null error; nothing on the message.error text, and no OK button on it either): A breakpoint in the "sgmnt = Read #m_tty As Object" line show that the value of "dLen" is three, which is OK. But when I try to READ As String, the leading 0x02 is missing from the string, leaving only 0x15-0x03. When this is later compared to TEST_RX in Test(), the comparison obviously fails. Hope someone can help me out. I guess my heavy VB6 background is interfering but can't really see how. TIA, zxMarce. -- View this message in context: http://gambas.8142.n7.nabble.com/Serial-Port-issues-and-events-tp56614.html Sent from the gambas-user mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user