Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.35k stars 287 forks source link

How to read data from Digital balance, using RS-232C to USB #338

Closed AdelDima closed 2 years ago

AdelDima commented 3 years ago

Hello,

I have used jSerialComm sending data to VFD Display using COM port and it was a great experience.

Now, I want to read data from Digital balance that use RS-232C to USB, In order to read I used getInputStream() and to manage event listening I used addDataListener()

Console message

com.fazecast.jSerialComm.SerialPortTimeoutException: The read operation timed out before any data was returned.

If I changed Read Time out to 0 serialPort.setComPortTimeouts ( SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 0, 0 ); It never stops and it did not log into serialEvent().

If anyone manages to use this with RS-232C Digital balance, I'll appreciate your help, in main time I'll keep updating this issue if I find any solution I'll post it here.

Thank You!

AdelDima commented 3 years ago

In the last few days, I understand that it depends on the Balance type, for me I'm using CAS Scales, and it required write([0x05, 0x11]) before reding , anyway I managed to read it using python

ser = serial.Serial(port='COM3', baudrate=9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, timeout=3)

try:
    ser.isOpen()
    print("Serial port is open")
except:
    print("ERROR")
    exit()

if ser.isOpen():
    while True:
        ser.write([0x05, 0x11])
        print(ser.readline())

else:
    print("Cannot open serial port") 

Now, I'm trying to make it work with jSerialComm/java

cgallaty commented 3 years ago

I've had luck getting my postal scale working with JSerialComm. Had a devil of a time finding the protocol on the net. The scale I have just keeps dumping the current value out and you have to just catch it based on analyzing the framing of the packet. If you know how your unit talks, you are half way there.

C4J commented 3 years ago

I have got it working with Mettler Toledo and Avery scales. You can get my source code via links on the project home page http://www.commander4j.com

hedgecrw commented 2 years ago

Can this issue be closed? It seems to be unrelated to jSerialComm, but I don't want to close it that's not correct.

hedgecrw commented 2 years ago

Assuming this issue has been resolved...