kuka-isir / ati_sensor

C++ Libraries to communicate with the ATI NET F/T box.
Other
11 stars 8 forks source link

Follow-up of #13 on failure at init #16

Closed guihomework closed 6 years ago

guihomework commented 6 years ago

Modified failure detection to stop at first major error and improved error messages

As discussed in #13

Not all failure case could be tested, don't know how to produce them. But the main fail described in #13 looks like this now

process[rh/ft_sensor-1]: started with pid [350]
[ INFO] [1508921479.215189932]: ATISensor IP : 192.168.10.100
[ INFO] [1508921479.215274299]: ATISensor frame : /ati_link
Could not connect to 192.168.10.100:80       => is in normal red
openSockets error: failed to connect to socket   => is bold red
Error during initialization, FT sensor NOT started   => is bold red
Sensor shutdown sucessfully
[FATAL] [1508921482.279232529]: Failed with error : FT sensor could not initialize  => is normal red coming from the node handling the init fail.
ahoarau commented 6 years ago

Thanks for the PR. Could you also add the prefix [ftsensor up:port] for all messages ?

guihomework commented 6 years ago

@ahoarau back from holiday, finishing working on it asap

guihomework commented 6 years ago

Fixed header and tested locally. when working

[ INFO] [1510769573.025842534]: ATISensor IP : 192.168.10.100
[ INFO] [1510769573.025920675]: ATISensor frame : /ati_frame
[ft_sensor 192.168.10.101:49152] Start realtime streaming with 1 samples
[ft_sensor 192.168.10.101:49152] Using current calibration
[ft_sensor 192.168.10.101:49152] Sucessfully retrieved counts per force : 1000000
[ft_sensor 192.168.10.101:49152] Sucessfully retrieved counts per torque : 1000000
[ INFO] [1510769573.058763111]: ATISensor RDT Rate : 7000

when fails

[ INFO] [1510772385.124127616]: ATISensor IP : 192.168.10.100
[ INFO] [1510772385.124198430]: ATISensor frame : /ati_link
[ft_sensor 192.168.10.100:49152] Could not connect to 192.168.10.100
[ft_sensor 192.168.10.100:49152] openSockets error: failed to connect to socket
[ft_sensor 192.168.10.100:49152] Error during initialization, FT sensor NOT started
[ft_sensor 192.168.10.100:49152] Sensor shutdown sucessfully
[FATAL] [1510772403.495391524]: Failed with error : FT sensor could not initialize
ahoarau commented 6 years ago

Good. Tiny remark : Sensor shutdown sucessfully is not necessary (?)

guihomework commented 6 years ago

I inverted the test to create a message if not shutting down properly

ahoarau commented 6 years ago

Shall we remove this message instead ? If sensor is not present, then the shutdown cannot be 'not successful' :)

guihomework commented 6 years ago

I think it is important to know when open sockets could not close correctly. The closing should handle the fact that the socket might not have been open (so should succeed to close something not open).

However I have doubts on how it was handled before my change : https://github.com/kuka-isir/ati_sensor/blob/master/src/ft_sensor.cpp#L308 returns true if the return value is positive on both. However positive will never occur because close is never positive (https://linux.die.net/man/2/close) So return was always false, so always 0

I suggest the following.

ahoarau commented 6 years ago

100% agree :+1:

guihomework commented 6 years ago

I fixed it and there is no message shown, even if badly disconnecting and such (probably because it never fails to close the handler)