Mercurial > hg > fxanalyse
view KKFX80E.c @ 99:dad4414051c4
Add 'KK_FX80E.dll' to the distributed files
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Tue, 26 Mar 2013 18:23:29 +0100 |
parents | c9e4f63c2033 |
children | 4f1f353e84f5 |
line wrap: on
line source
#include <ctype.h> #include <windows.h> int (_stdcall *FX_OpenPort)(char **Port) = NULL; void (_stdcall *FX_ClosePort)(void) = NULL; int (_stdcall *FX_SendCommand)(char **Command) = NULL; int (_stdcall *FX_GetReport)(char **Data) = NULL; void (_stdcall *FX_Debug)(BOOL DbgFlag) = NULL; // int (_stdcall *GetFXM)(char **Data) = NULL; // void (_stdcall *Log)(int DbgNum) = NULL; // int (_stdcall *ReadMonitor)(char **Data) = NULL; // BOOL (_stdcall *EnumeratePorts)(char **PortName, char *PortNamePrefix) = NULL; static HMODULE module; int FX_Init(void) { FARPROC funcp; module = LoadLibrary("KK_FX80E.dll"); if (! module) return 0; funcp = GetProcAddress(module, "FX_OpenPort"); if (! funcp) goto error; FX_OpenPort = (void *)funcp; funcp = GetProcAddress(module, "FX_ClosePort"); if (! funcp) goto error; FX_ClosePort = (void *)funcp; funcp = GetProcAddress(module, "FX_SendCommand"); if (! funcp) goto error; FX_SendCommand = (void *)funcp; funcp = GetProcAddress(module, "FX_GetReport"); if (! funcp) goto error; FX_GetReport = (void *)funcp; funcp = GetProcAddress(module, "FX_Debug"); if (! funcp) goto error; FX_Debug = (void *)funcp; return 1; error: FreeLibrary(module); return 0; } void FX_Free(void) { FreeLibrary(module); } int FX_Open(char *port) { int rv = FX_OpenPort(&port); #ifdef DEBUG if (! rv) fprintf(stderr, "%s\n", *port); #endif return rv; } void FX_Close(void) { FX_ClosePort(); } int FX_Send(char *cmd) { int rv = FX_SendCommand(&cmd); #ifdef DEBUG if (! rv) fprintf(stderr, "%s\n", cmd); #endif return rv; } char * FX_Recv(char **ret) { int rv; char *data; do { data = "."; rv = FX_GetReport(&data); } while (! data); #ifdef DEBUG if (! rv) fprintf(stderr, "%s\n", data); #endif if (! rv) return NULL; if (ret) *ret = data; return data; }