/*--------------------------------------------------------------------------- L H 4 5 U T I L A few utility functions for talking to a Julabo LH45 temperature controller via the SINQ setup: TCP/IP--MAC--RS-232-- LH45. Mark Koennecke, Juli 1997 Mark Lesha, January 2006 (based on ITC4 code) ----------------------------------------------------------------------------*/ #ifndef SINQLH45 #define SINQLH45 /*----------------------- ERRORCODES-------------------------------------- Most functions return a negative error code on failure. Error codes defined are those defined for serialsinq plus a few additional ones: */ #define LH45__BADCOM -501 /* command not recognized */ #define LH45__BADPAR -502 /* bad parameter to command */ #define LH45__BADMALLOC -503 /* error allocating memory */ #define LH45__BADREAD -504 /* error analysing command string on Read */ #define LH45__FAULT -505 /* fault or overload condition exists in LH45 */ #define LH45__NOLH45 -510 /* Controller is not LH45 */ #define LH45__BADSET -530 /* failed three times to set temperature */ #define LH45__READONLY -531 /*------------------------------------------------------------------------*/ typedef struct __LH45 { int iRead; int iControl; void *pData; char pAns[80]; /* should be enough for LH45 errors */ /* The LH45 does not need multipliers or dividers but leave them in anyway for back compatibility or future use but force the value to 1.0 all the time */ float fDiv; float fMult; int iReadOnly; prs232 controller; } LH45; typedef struct __LH45 *pLH45; /*-----------------------------------------------------------------------*/ int LH45_Open(pLH45 *pData,char *pHost, int iPort, int iChannel, int iMode); /***** creates an LH45 datastructure and opens a connection to the LH45 controller. Input Parameters are: the hostname the port number the RS-232 channel number on the Mac. iMode: 1 for ReadOnly, 0 for normal mode Return values are 1 for success, a negative error code on failure. */ void LH45_Close(pLH45 *pData); /****** close a connection to an LH45controller and frees its data structure. The only parameter is a pointer to the data structure for this controller. This pointer will be invalid after this call. */ int LH45_Config(pLH45 *pData, int iTmo, int iRead, int iControl, float fDiv, float fMult); /***** configure some aspects of a LH45temperature controller. The parameter are: - a pointer to the data structure for the controller as returned by LH45_Open - a value for the connection timeout - the temperature sensor to use for reading the temperature. - the temperature sensor used by the LH45controller for regulating the temperature. - the divisor needed to calculate the real temperature from the sensor. The function returns 1 on success, a negative error code on failure. */ int LH45_Send(pLH45 *pData, char *pCommand, char *pReply, int iLen); /******* send a the command in pCommand to the LH45controller. A possible reply is returned in the buffer pReply. Maximum iLen characters are copied to pReply. The first parameter is a pointer to a LH45data structure as returned by LH45_Open. Return values are 1 for success, a negative error code on failure. */ int LH45_Read(pLH45 *pData, float *fVal); /******* reads the current actual temperature of the sensor configured by ConfigLH45for reading. The value is returned in fVal. The first parameter is a pointer to a LH45 data structure as returned by LH45_Open. Return values are 1 for success, a negative error code on failure. */ int LH45_Set(pLH45 *pData, float fVal); /****** sets a new preset temperature in the LH45temperature controller. Parameters are: - a pointer to a LH45data structure as returned by LH45_Open. - the new preset value. Return values are 1 for success, a negative error code on failure. */ void LH45_ErrorTxt(pLH45 *pData, int iCode, char *pError, int iLen); /******* translates one of the negative error LH45error codes into text. Maximum iLen bytes will be copied to the buffer pError; */ #endif