83 lines
2.4 KiB
C
83 lines
2.4 KiB
C
#ifndef ASCON_H
|
|
#define ASCON_H
|
|
|
|
#include "sics.h"
|
|
#include "errormsg.h"
|
|
|
|
/** \file
|
|
* \brief Asynchronous connection handling for devices controlled over tcp-ip
|
|
* connections. Interface for higher level modules.
|
|
*/
|
|
|
|
/** \brief the asynchronous connection
|
|
*/
|
|
typedef struct Ascon Ascon;
|
|
|
|
/** \brief the possible results of AsconTask
|
|
*/
|
|
typedef enum {
|
|
AsconOffline,
|
|
AsconUnconnected,
|
|
AsconPending,
|
|
AsconReady,
|
|
AsconFailure
|
|
} AsconStatus;
|
|
|
|
/** \brief make a new asynchronous connection
|
|
* \param con the SICS connection
|
|
* \param argc number of arguments
|
|
* \param argv the arguments. argv[0] must be the protocol name, the other arguments
|
|
* are protocol specific, but argv[1] is usually host::port
|
|
* \return the created connection or NULL on failure
|
|
*/
|
|
Ascon *AsconMake(SConnection *con, int argc, char *argv[]);
|
|
|
|
/** \brief kill function
|
|
* \param a the connection to be killed
|
|
*/
|
|
void AsconKill(Ascon *a);
|
|
|
|
/** \brief the task handler. To be called repeatedly.
|
|
* \param a the connection
|
|
* \return the state of the connection
|
|
*/
|
|
AsconStatus AsconTask(Ascon *a);
|
|
|
|
/** \brief write to the connection. allowed only when the state is AsconReady
|
|
* \param a the connection
|
|
* \param command the command to be sent
|
|
* \param noResponse 0 normally, 1 if no reponse is expected
|
|
* \return 1 on success, 0 when not ready
|
|
*/
|
|
int AsconWrite(Ascon *a, char *command, int noResponse);
|
|
|
|
/** \brief read from the connection. allowed only when a response is available
|
|
* \param a the connection
|
|
* \return the response when a response is ready
|
|
* NULL when the command has not completed and the response is not yet finished
|
|
* "" when the command has completed, but no response was expected.
|
|
* The result is only valid until the next call to other AsconXxx functions
|
|
* and has to be duplicated if needed later.
|
|
*/
|
|
char *AsconRead(Ascon *a);
|
|
|
|
/** \brief get the connections error list
|
|
* \return the error list
|
|
*/
|
|
ErrMsg *AsconGetErrList(Ascon *a);
|
|
|
|
/** \brief a helper function
|
|
* \param argc the number of args
|
|
* \param argv the args to be concatenated
|
|
* \result a allocated string containing the concatenated arguments
|
|
* the args are properly quoted to be used as tcl proc arguments
|
|
*/
|
|
char *ConcatArgs(int argc, char *argv[]);
|
|
|
|
/** \brief function for dealing with times with musec resolution
|
|
* \return absolute time as double value
|
|
*/
|
|
double DoubleTime(void);
|
|
|
|
#endif
|