Hi there,
I've implemented a full RegisterStatusChangeCB handler, and have been successful in trapping device changes and acting upon them, but I have an interesting corner case that I'm trying to work through. I have a few legacy devices that are being monitored by a microcontroller, and then an ASCII string is emitted when that legacy device toggles.
What I am trying to figure out is how I can update the status and value without RegisterStatusChangeCB even knowing about it. What ends up happening now is:
- legacy device changes and ASCII is emitted
- ASCII received, COM port script updates virtual device state via HS calls
- virtual device state update from COM port script causes RegisterStatusChangeCB to be called
- RegisterStatusChangeCB script detects virtual device change and causes ASCII to be emitted
- the ASCII emitted to microcontroller tells the legacy device to change its state to what it was already just changed to
Fortunately the loop stops there, because the legacy device is already at this new state, but this is a lot of unnecessary extra work, and could create a race condition.
CAPIControlHandler is the default mechanism for updating the virtual device, but that obviously will cause the CB to be executed.
I also tried SetDeviceValueByName and SetDeviceStringByName, but that also causes the CB to be executed.
Does anyone know if there is a way to set the device value and status "silently"?
Thanks,
Chris
I've implemented a full RegisterStatusChangeCB handler, and have been successful in trapping device changes and acting upon them, but I have an interesting corner case that I'm trying to work through. I have a few legacy devices that are being monitored by a microcontroller, and then an ASCII string is emitted when that legacy device toggles.
What I am trying to figure out is how I can update the status and value without RegisterStatusChangeCB even knowing about it. What ends up happening now is:
- legacy device changes and ASCII is emitted
- ASCII received, COM port script updates virtual device state via HS calls
- virtual device state update from COM port script causes RegisterStatusChangeCB to be called
- RegisterStatusChangeCB script detects virtual device change and causes ASCII to be emitted
- the ASCII emitted to microcontroller tells the legacy device to change its state to what it was already just changed to
Fortunately the loop stops there, because the legacy device is already at this new state, but this is a lot of unnecessary extra work, and could create a race condition.
CAPIControlHandler is the default mechanism for updating the virtual device, but that obviously will cause the CB to be executed.
I also tried SetDeviceValueByName and SetDeviceStringByName, but that also causes the CB to be executed.
Does anyone know if there is a way to set the device value and status "silently"?
Thanks,
Chris
Comment