8. Diagnostics

All functions return -1 if an error occurs. Typically, the functions will return 0 on success, but the data exchange functions (cs_get, cs_put, cs_more) follow special rules. Consult their descriptions.

The error code for the COMSTACK can be retrieved using C macro cs_errno which will return one of the error codes CSYSERR, CSOUTSTATE, CSNODATA, ...

    int cs_errno(COMSTACK handle);
   

You can the textual representation of the error code by using cs_errmsg, which works like strerror(3).

    const char *cs_errmsg(int n);
   

It is also possible to get straight to the textual representation without the error code, by using cs_strerror.

    const char *cs_strerror(COMSTACK h);