Beckhoff / ADS

Beckhoff protocol to communicate with TwinCAT devices.
MIT License
502 stars 194 forks source link

AmsConnection::AdsRequest check Nullpointer to router #102

Open mriepl opened 4 years ago

mriepl commented 4 years ago

I check in an extra thread by calling the "AdsSyncReadDeviceInfoReqEx" function if the plc is still alive (every second). When i get an Error (eg. 1861) i do "AdsDelRoute" and try to connect again via "AdsAddRoute" in a loop.

This occure sometimes when i restart the remote system via cerhost. What can be the reason?

nullptr

callhisotry: I save all the handles for notifications, when the connection breaks i want to release the notification, this doesnt work so i save the "corrupt" handles in an error list. when i get the connection back i want to delete old device notification handles. Call: CloseErrors().

Aufrufhirachie

On a lucky punch everything worked fine and the logging looks like this: 1+2.) Get Timeout and "AdsDelRoute" 3.) AdsAddRoute() == 0 (no error) 4.) Delete old Notifications and Handles. I dont close the Ports which i got with "AdsPortOpenEx"

lucky

pbruenn commented 4 years ago

Oh okay, I think I know what might be the problem. NotificationDispatcher::erase() calls a callback function, which was bound to an AmsConnection instance. But that instance could be deleted by AdsDelRoute().