How can Counter values be read in Python?

Made good progress using python for some daq and alarming applications (EPIC and RIO) with custom MQTT publishing. So far I’m using the optommp package in python, it is only able to read ANALOG and DIGITALs as straight values (same as what displays in the IO panel in groovmanage it seems. For counter channels, this shows the state of the digital channel, 1 or 0, but how would you read the counter value it is counting in python?

It could be read by publishing the counter to a mqtt broker and reading that back I see (not ideal) and wondering if any better way to read the counter value itself in python? Do the API’s let you read this? I’ve not played with them yet but will if they can do it. Ideally something that works on RIO and EPIC devices.

Suggestions?
Thanks

Looks like the python library has a ReadRawOffset function where you can read any mem map location you want.

  • ReadRawOffset(offset, size, data_type) - Rads the raw address at offset, collecting size bytes, and using data_type formatting to unpack it (see UnpackReadResponse for details).

With that and doc 1465 to find the memory map location you should get what you need.

3 Likes

Thanks @philip, I havn’t exploring doing any manual reads yet like that, so will have to go in that direction then (or use Rest API for slow speed access) but its a bit large to dive into at first look so thought I’d ask if any other guidance. 200 mentions of counter in the protocol guide and obviously a lot to explore and read about still then. I do appreciate the point in that direction though, any other tips to read counters directly or as a starting point would be appreciated.

Thanks

Look for the [(Expanded) Digital Channel Read-Read Only] section.

The counter value for channel 0 would be at 0xF01E0010, channel 1 would be at 0xF01E0050, etc.

3 Likes

Awesome Thanks Philip, was looking at the wrong spot and that gets my counter value perfectly and gives me a great start. Appreciate that, saved me a bunch of trial and error to start. :slight_smile:

2 Likes