- introduce script context
This commit is contained in:
81
ascon.h
Normal file
81
ascon.h
Normal file
@ -0,0 +1,81 @@
|
||||
#ifndef ASCON_H
|
||||
#define ASCON_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 *AsconPtr;
|
||||
|
||||
/** \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
|
||||
*/
|
||||
AsconPtr AsconMake(SConnection *con, int argc, char *argv[]);
|
||||
|
||||
/** \brief kill function
|
||||
* \param a the connection to be killed
|
||||
*/
|
||||
void AsconKill(AsconPtr a);
|
||||
|
||||
/** \brief the task handler. To be called repeatedly.
|
||||
* \param a the connection
|
||||
* \return the state of the connection
|
||||
*/
|
||||
AsconStatus AsconTask(AsconPtr a);
|
||||
|
||||
/** \brief write to the connection. allowed only when the state is ascon_ready
|
||||
* \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(AsconPtr 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(AsconPtr a);
|
||||
|
||||
/** \brief get the connections error list
|
||||
* \return the error list
|
||||
*/
|
||||
ErrMsgList *AsconGetErrList(AsconPtr 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
|
Reference in New Issue
Block a user