I am trying to connect weight machine with my programm. I am using o connection with RS232.
I have created a serialConnection and made a connection. But the DataReceived Never firing.Can you help me so i can fire the DataReceived?


this is my code.I am using the connection on another method in specific COM and BAUD

Hi Nikos - have you tested the serial comms of this scale using another Terminal program? In other words, does the scale send/receive data if you communicate with it manually via any other program?

And, is the SerialConnection object staying in scope whereby the object is still alive when the DataReceived event happens?

Hi William, yes it works with an old version with some old code that i have, but when the Serial changed to SerialConnection it connects but it doesn’t write something and the DataReceived never happens.
Do you have any idea what i can change so the DataReceived event can happen

We should probably start by looking at how you instantiate the SerialConnection, as it has changed over time and the property values you used in the past may need to be updated. Below is a snippet from my Open event on an app that uses a serial barcode scanner. How does this compare to the setup you’re using with your own SerialConnection?

// Create new SerialConnection object
GFS4400.Scanner = New SerialConnection
GFS4400.Scanner.Baud = SerialConnection.Baud115200
GFS4400.Scanner.Bits = SerialConnection.Bits8
GFS4400.Scanner.StopBit = SerialConnection.StopBits.One
GFS4400.Scanner.Parity = SerialConnection.Parities.None

AddHandler GFS4400.Scanner.DataReceived, AddressOf ScanDataReceived_action

If you are using SerialConnection in that way you have to endure that the object doesn’t go out of scope, otherwise it is destroyed. You can avoid this sort of thing by making it a property of the window or some other object that exists as long as the process is working.

Also note that the use of Flush on the Serial object may be compromised on newer versions of Xojo. Refer to SerialConnection.Flush wipes out input buffer (#75917) · Issues · Xojo Inc / Xojo · GitLab. I only mention this since you include the use of Flush in your description and also that a previous version seemed to work.