Open keenanjohnson opened 1 month ago
Can you share complete code snippet you are trying to run?
print('Symbol Info: 'en_symbol)
This line contains a typo, there is a coma missing.
Generally there is no symbol type BIT
, there is PLCTYPE_BOOL
.
So sorry yes that code snippet is complete minus the typo there.
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)
There does indeed seem to be a bit type when I use the beckhoff tools to inspect the target. Perhaps the bit type is not exposed via ADS?
See the screenshot of the target browser of my PLC
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
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