[Python][Raspberry][Weight measuring scale with Protocol Dialog06] Unable to communicate with scale

I have a Mettler Toledo Ariva-S scale connected in COM port-> USB port on a raspberry pi.

I’ve configured the Mettler Toledo scale to use the Dialog 06 protocol.

I’m coding in python and I’m trying to get the weight from the scale but I’m not succeeding. The scale only replies b”.

The scale is connected to the raspberry’s /dev/ttyUSB0 serial port.

pi@raspberrypi:~ $ find -L /dev/serial/by-path/ -samefile /dev/ttyUSB0

/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.1:1.0-port0

The principle of the Dialog 06 protocol is to send the unit price of the product weighed, as well as any tare values, directly to the scale.

The scale returns the measured weight and the final price of the product weighed (minus the tare).
This eliminates the need for price manipulations to remove the tare at a later stage, once the weight has been recovered.

In my code, I only try to send the unit price of the product to the scale, but I get no response.

I don’t understand at all why the scale doesn’t answer me.

Does anyone have any idea what I’m doing wrong?

Here’s my code:

import serial

port_config = {
  baudrate': 9600,
  bytesize': 7,
  stopbits': 1,
  parity': 'O',
  timeout': 1
  writeTimeout': 1
}

path = '/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.1:1.0-port0'

# --------------------------------------------------------
# Establishing the connection with the scale
# --------------------------------------------------------

connection = serial.Serial(path, port_config)

_logger.info("Connection dict : {}".format(connection.__dict__))

Logs

Connection dict = {‘is_open’: True, ‘portstr’: ‘/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.1:1.0-port0’, ‘name’: ‘/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.1:1.0-port0’, ‘_port’: ‘/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.1:1.0-port0’, ‘_baudrate’: 9600, ‘_bytesize’: 7, ‘_parity’: ‘O’, ‘_stopbits’: 1, ‘_timeout’: 1, ‘_write_timeout’: 1, ‘_xonxoff’: False, ‘_rtscts’: False, ‘_dsrdtr’: False, ‘_inter_byte_timeout’: None, ‘_rs485_mode’: None, ‘_rts_state’: True, ‘_dtr_state’: True, ‘_break_state’: False, ‘_exclusive’: None, ‘fd’: 13, ‘pipe_abort_read_r’: 14, ‘pipe_abort_read_w’: 15, ‘pipe_abort_write_r’: 16, ‘pipe_abort_write_w’: 17}

# --------------------------------------------------------
# Ask the scale weight with the unit price
# --------------------------------------------------------

unit_price = "001000"
message_to_send = "{}{}{}{}{}{}".format(protocol.eot_stx,protocol.record_01,protocol.esc,unit_price,protocol.esc,protocol.etx).encode("utf-8")

# EOT = End of Transmission = x04
# STX = Start of Text = x02
# ESC = Escape = x1B
# ETX = End of Text = x03
# RECORD_01 = 01
# COMMNAND_DELAY = 0.2
# {x04x02}{RECORD_01}{x1B}{unit_price}{x1B}{x03}

connection.write(message_to_send)

_logger.info("message_to_send : {}".format(message_to_send))

Logs

message_to_send : b’x04x0201x1b001000x1bx03′

# --------------------------------------------------------
# Get the scale response
# --------------------------------------------------------

time.sleep(protocol.commandDelay)

answer = []
while True:
 char = connection.read(1)
 if not char:
    break
 else:
    answer.append(bytes(char))

response = b''.join(answer)
_logger.info("answer : {}".format(response))

Logs

answer : b”

I’ve never tried to code message exchanges with a scale so I guess I’m doing something wrong but I can’t put my finger on the problem at all.

I used the Ariva-S documentation (pages 17-19) to configure the scale, and descriptive document for the Dialog 06 protocol to code the message exchange in python.

I thank in advance anyone who can help me or point me in the right direction.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật