You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However when I try to read and write to it with the pyads library I get some errors
For example the code below throws the error below:
Perhaps I'm doing something incorrectly? I've tried writing both Python bool values and numeric values to the same result.
Code
en_symbol = plc.get_symbol('device.ch1')
print('Symbol Info: 'en_symbol)
print('Symbol Type: ', en_symbol.symbol_type)
# Try to write the Channel
en_symbol.write(True)
Error
<pyads.symbol.AdsSymbol object at 0x7ffffea47470, name: device.ch1, type: BIT>
En channel 1 value: BIT
Traceback (most recent call last):
File "/workspaces/main.py", line 108, in <module>
en_symbol.write(True)
File "/usr/local/lib/python3.12/site-packages/pyads/symbol.py", line 221, in write
self._plc.write(self.index_group, self.index_offset, new_value, self.plc_type)
File "/usr/local/lib/python3.12/site-packages/pyads/connection.py", line 292, in write
return adsSyncWriteReqEx(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyads/pyads_ex.py", line 636, in adsSyncWriteReqEx
data = plc_data_type(value)
^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable
2024-07-31T20:24:31+0000 Info: connection closed by remote
Segmentation fault
The text was updated successfully, but these errors were encountered:
PLC type BIT is currently not supported directly, however if you specify the type as pyads.PLCTYPE_BYTE it reads them just fine, I don't know if you can actually read a bit directly over ADS (or if it then makes it a byte). I will have to experiment.
e.g. plc.read_by_name("device.ch1", pyads.PLCBYTE_BOOL) or symbol = plc.get_symbol('device.ch1'), symbol.plc_type = pyads.PLCTYPE_BYTE
chrisbeardy
changed the title
Issues Reading and Writing PLC BIT Type
ADD direct support for PLC BIT Type (PLCTYPE_BIT)
Aug 13, 2024
Hey all!
I have a PLC variable of type BIT.
However when I try to read and write to it with the pyads library I get some errors
For example the code below throws the error below:
Perhaps I'm doing something incorrectly? I've tried writing both Python bool values and numeric values to the same result.
Code
Error
The text was updated successfully, but these errors were encountered: