pycomm3 icon indicating copy to clipboard operation
pycomm3 copied to clipboard

Writing REAL value in generic_message

Open yu5800 opened this issue 1 year ago • 1 comments

Hello, I'm having trouble communicating with a mass flow controller via Ethernet/IP. In my application, I want to read and write data. I was able to successfully read data using generic_message. However, I haven't been able to write data (for example, setting the setpoint). Only INT values can be sent, not REAL values as described in the device documentation. So the setpoint is not set correctly. I'm not sure if I need to input something else or if it's the device itself. Here's my code:

with CIPDriver(ip) as drive:
        read_setpoint = drive.generic_message(
            service=Services.get_attribute_single,
            class_code=b'\x65',
            instance=b'\x01', 
            attribute=b'\x03',
            data_type=REAL,
            connected=False,
            #unconnected_send=True, 
            route_path=True,
            name='Read Setpoint'
        )
with CIPDriver(ip) as drive:
        write_setpoint = drive.generic_message(
            service=Services.set_attribute_single,
            class_code=b'\x65',
            instance=b'\x01', 
            attribute=b'\x03',
            request_data=REAL.encode(10),
            data_type=REAL,
            connected=False,
            #unconnected_send=True, 
            route_path=True,
            name='Write Setpoint'
        )

With print(read_setpoint) I get the output Read Setpoint, 0.0, REAL, None With print(write_setpoint) I get the output Write Setpoint, None, REAL, Too much data

yu5800 avatar Apr 11 '24 09:04 yu5800

See #279, there has been some luck setting route_path to false and/or none.

Colt-H avatar May 01 '24 12:05 Colt-H