/* The organization of this file is modelled after the motorforce example developed by Uros Platise. */ #include #include #include #if !defined(_MSC_VER) && !defined(__MINGW64__) #include #endif #if defined(_MSC_VER) #include #include #include #endif #include "d_process.h" #define DIGITAL_IN 0 #define DIGITAL_OUT 4 static int compute(uint8_t *dataout, int outsz, double time); //#define ENABLE_DEBUGGING 1 #ifdef ENABLE_DEBUGGING static int known_bp(int iargc) { return iargc; } #endif int main(int argc, char *argv[]) { int i; int outlen = D_PROCESS_DLEN(DIGITAL_OUT); #if defined(_MSC_VER) || defined(__MINGW64__) #pragma pack(push, 1) struct in_s { double time; } in; struct out_s { uint8_t dout[D_PROCESS_DLEN(DIGITAL_OUT)]; } out; #pragma pack(pop) #else struct in_s { double time; } __attribute__((packed)) in; struct out_s { uint8_t dout[D_PROCESS_DLEN(DIGITAL_OUT)]; } __attribute__((packed)) out; #endif int pipein = 0; // default stdin to recv from ngspice int pipeout= 1; // default stdout to send to ngspice #if defined(_MSC_VER) || defined(__MINGW64__) _setmode(0, _O_BINARY); _setmode(1, _O_BINARY); #endif #ifdef ENABLE_DEBUGGING #if defined(_MSC_VER) || defined(__MINGW64__) fprintf(stderr, "%s pid %d\n", argv[0], _getpid()); #else fprintf(stderr, "%s pid %d\n", argv[0], getpid()); #endif #if !defined(_MSC_VER) && !defined(__MINGW64__) if (getenv("GO_TO_SLEEP")) { sleep(40); } #endif #if defined(__MINGW64__) if (getenv("GO_TO_SLEEP")) { sleep(40); } #endif #if defined(_MSC_VER) if (getenv("GO_TO_SLEEP")) { Sleep(60000); } #endif (void)known_bp(argc); #endif for (i=0; i> 1)) & 0x0F; return 1; }