gpibinter.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. /***********************************************************
  2. * Python wrapper module for gpib library functions.
  3. ************************************************************/
  4. #include "Python.h"
  5. #ifdef USE_INES
  6. #include <ugpib.h>
  7. #else
  8. #include <gpib/ib.h>
  9. #endif
  10. #include <errno.h>
  11. #include <unistd.h>
  12. #include <stdio.h>
  13. #include <string.h>
  14. static PyObject *GpibError;
  15. struct _iberr_string {
  16. int code;
  17. char *meaning;
  18. } _iberr_string;
  19. static struct _iberr_string GPIB_errors[] = {
  20. {EDVR, "A system call has failed. ibcnt/ibcntl will be set to the value of errno."},
  21. {ECIC, "Your interface board needs to be controller-in-charge, but is not."},
  22. {ENOL, "You have attempted to write data or command bytes, but there are no listeners currently addressed."},
  23. {EADR, "The interface board has failed to address itself properly before starting an io operation."},
  24. {EARG, "One or more arguments to the function call were invalid."},
  25. {ESAC, "The interface board needs to be system controller, but is not."},
  26. {EABO, "A read or write of data bytes has been aborted, possibly due to a timeout or reception of a device clear command."},
  27. {ENEB, "The GPIB interface board does not exist, its driver is not loaded, or it is in use by another process."},
  28. {EDMA, "Not used (DMA error), included for compatibility purposes."},
  29. {EOIP, "Function call can not proceed due to an asynchronous IO operation (ibrda(), ibwrta(), or ibcmda()) in progress."},
  30. {ECAP, "Incapable of executing function call, due the GPIB board lacking the capability, or the capability being disabled in software."},
  31. {EFSO, "File system error. ibcnt/ibcntl will be set to the value of errno."},
  32. {EBUS, "An attempt to write command bytes to the bus has timed out."},
  33. {ESTB, "One or more serial poll status bytes have been lost. This can occur due to too many status bytes accumulating (through automatic serial polling) without being read."},
  34. {ESRQ, "The serial poll request service line is stuck on."},
  35. {ETAB, "This error can be returned by ibevent(), FindLstn(), or FindRQS(). See their descriptions for more information."},
  36. {0, NULL},
  37. };
  38. void _SetGpibError(const char *funcname)
  39. {
  40. char *errstr;
  41. struct _iberr_string entry;
  42. int sverrno, code;
  43. code = ThreadIberr();
  44. errstr = (char *) PyMem_Malloc(4096);
  45. if (code == EDVR || code == EFSO) {
  46. sverrno = ThreadIbcntl();
  47. snprintf(errstr, 4096, "%s() error: %s (errno: %d)",
  48. funcname, strerror(sverrno), sverrno);
  49. } else {
  50. int i;
  51. for (i=0; entry=GPIB_errors[i], entry.meaning!=NULL; i++) {
  52. if (entry.code == code)
  53. break;
  54. }
  55. if (entry.meaning != NULL)
  56. snprintf(errstr, 4096, "%s() failed: %s",
  57. funcname, entry.meaning);
  58. else
  59. snprintf(errstr, 4096,
  60. "%s() failed: unknown reason (iberr: %d).", funcname, code);
  61. }
  62. PyErr_SetString(GpibError, errstr);
  63. PyMem_Free(errstr);
  64. }
  65. /* ----------------------------------------------------- */
  66. static char gpib_find__doc__[] =
  67. "find -- get a device handle from configuration file\n"
  68. "find(name) -> handle";
  69. static PyObject* gpib_find(PyObject *self, PyObject *args)
  70. {
  71. char *name;
  72. int ud;
  73. if (!PyArg_ParseTuple(args, "s:find", &name))
  74. return NULL;
  75. ud = ibfind(name);
  76. if(ud < 0){
  77. _SetGpibError("find");
  78. return NULL;
  79. }
  80. return PyInt_FromLong(ud);
  81. }
  82. static char gpib_dev__doc__[] =
  83. "dev -- get a device handle\n"
  84. "dev(boardid, pad, [sad, timeout, eot, eos_mode]) -> handle";
  85. static PyObject* gpib_dev(PyObject *self, PyObject *args)
  86. {
  87. int ud = -1;
  88. int board = 0;
  89. int pad = 0;
  90. int sad = NO_SAD;
  91. int tmo = T30s;
  92. int eot = 1;
  93. int eos_mode = 0;
  94. if (!PyArg_ParseTuple(args, "ii|iiii:dev", &board, &pad, &sad, &tmo, &eot, &eos_mode))
  95. return NULL;
  96. ud = ibdev(board, pad, sad, tmo, eot, eos_mode);
  97. if (ud < 0) {
  98. _SetGpibError("dev");
  99. return NULL;
  100. }
  101. return PyInt_FromLong(ud);
  102. }
  103. static char gpib_ask__doc__[] =
  104. "ask -- query configuration (board or device)\n"
  105. "ask(handle, option) -> result\n\n"
  106. "option should be one one of the symbolic constants gpib.IbaXXXX";
  107. static PyObject* gpib_ask(PyObject *self, PyObject *args)
  108. {
  109. int device;
  110. int option;
  111. int result;
  112. if (!PyArg_ParseTuple(args, "ii:ask", &device, &option))
  113. return NULL;
  114. if (ibask(device, option, &result) & ERR) {
  115. _SetGpibError("ask");
  116. return NULL;
  117. }
  118. return PyInt_FromLong(result);
  119. }
  120. static char gpib_config__doc__[] =
  121. "config -- change configuration (board or device)\n"
  122. "config(handle, option, setting)\n\n"
  123. "option should be one one of the symbolic constants gpib.IbcXXXX";
  124. static PyObject* gpib_config(PyObject *self, PyObject *args)
  125. {
  126. int device;
  127. int option;
  128. int setting;
  129. int sta;
  130. if (!PyArg_ParseTuple(args, "iii:config", &device, &option, &setting))
  131. return NULL;
  132. sta = ibconfig(device, option, setting);
  133. if(sta & ERR) {
  134. _SetGpibError("config");
  135. return NULL;
  136. }
  137. return PyInt_FromLong(sta);
  138. }
  139. static char gpib_listener__doc__[] =
  140. "listener -- check if listener is present (board or device)\n"
  141. "listener(handle, pad, [sad]) -> boolean";
  142. static PyObject* gpib_listener(PyObject *self, PyObject *args)
  143. {
  144. int device;
  145. int pad;
  146. int sad = NO_SAD;
  147. short found_listener;
  148. if(!PyArg_ParseTuple(args, "ii|i:listener", &device, &pad, &sad))
  149. return NULL;
  150. if(ibln(device, pad, sad, &found_listener) & ERR){
  151. _SetGpibError("listener");
  152. return NULL;
  153. }
  154. return PyBool_FromLong(found_listener);
  155. }
  156. static char gpib_read__doc__[] =
  157. "read -- read data bytes (board or device)\n"
  158. "read(handle, num_bytes) -> string";
  159. static PyObject* gpib_read(PyObject *self, PyObject *args)
  160. {
  161. int device;
  162. int len;
  163. PyObject *retval;
  164. if (!PyArg_ParseTuple(args, "ii:read", &device,&len))
  165. return NULL;
  166. /* Instead of using a C-buffer and then copying it into a
  167. Python-string, just build up an uninitialized Python-string.
  168. No copying needed, more efficient. (yes, this is legal, see
  169. http://www.python.org/doc/current/api/stringObjects.html) */
  170. retval = PyString_FromStringAndSize(NULL, len);
  171. if(retval == NULL)
  172. {
  173. PyErr_SetString(GpibError, "Read Error: can't get Memory.");
  174. return NULL;
  175. }
  176. if( ibrd(device, PyString_AS_STRING(retval), len) & ERR )
  177. {
  178. _SetGpibError("read");
  179. Py_DECREF(retval);
  180. return NULL;
  181. }
  182. _PyString_Resize(&retval, ThreadIbcntl());
  183. return retval;
  184. }
  185. static char gpib_write__doc__[] =
  186. "write -- write data bytes (board or device)\n"
  187. "write(handle, data)";
  188. static PyObject* gpib_write(PyObject *self, PyObject *args)
  189. {
  190. char *command;
  191. int command_len;
  192. int device;
  193. int sta;
  194. if (!PyArg_ParseTuple(args, "is#:write",&device, &command, &command_len))
  195. return NULL;
  196. sta = ibwrt(device, command, command_len);
  197. if( sta & ERR ){
  198. _SetGpibError("write");
  199. return NULL;
  200. }
  201. return PyInt_FromLong(sta);
  202. }
  203. static char gpib_write_async__doc__[] =
  204. "write_async -- write data bytes asynchronously (board or device)\n"
  205. "write_async(handle, data)";
  206. static PyObject* gpib_write_async(PyObject *self, PyObject *args)
  207. {
  208. char *command;
  209. int command_len;
  210. int device;
  211. int sta;
  212. if (!PyArg_ParseTuple(args, "is#:write_async", &device, &command, &command_len))
  213. return NULL;
  214. sta = ibwrta(device, command, command_len);
  215. if( sta & ERR ){
  216. _SetGpibError("write_async");
  217. return NULL;
  218. }
  219. return PyInt_FromLong(sta);
  220. }
  221. static char gpib_command__doc__[] =
  222. "command -- write command bytes (board)\n"
  223. "command(handle, data)";
  224. static PyObject* gpib_command(PyObject *self, PyObject *args)
  225. {
  226. char *command;
  227. int command_len;
  228. int device;
  229. int sta;
  230. if (!PyArg_ParseTuple(args, "is#:command", &device, &command, &command_len))
  231. return NULL;
  232. sta = ibcmd(device, command, command_len);
  233. if ( sta & ERR ) {
  234. _SetGpibError("cmd");
  235. return NULL;
  236. }
  237. return PyInt_FromLong(sta);
  238. }
  239. static char gpib_remote_enable__doc__[] =
  240. "remote_enable -- set remote enable (board)\n"
  241. "remote_enable(handle, enable)";
  242. static PyObject* gpib_remote_enable(PyObject *self, PyObject *args)
  243. {
  244. int device;
  245. int val;
  246. int sta;
  247. if (!PyArg_ParseTuple(args, "ii:remote_enable", &device,&val))
  248. return NULL;
  249. sta = ibsre(device,val);
  250. if( sta & ERR){
  251. _SetGpibError("remote_enable");
  252. return NULL;
  253. }
  254. return PyInt_FromLong(sta);
  255. }
  256. static char gpib_clear__doc__[] =
  257. "clear -- clear device (device)\n"
  258. "clear(handle)";
  259. static PyObject* gpib_clear(PyObject *self, PyObject *args)
  260. {
  261. int device;
  262. int sta;
  263. if (!PyArg_ParseTuple(args, "i:clear", &device))
  264. return NULL;
  265. sta = ibclr(device);
  266. if( sta & ERR){
  267. _SetGpibError("clear");
  268. return NULL;
  269. }
  270. return PyInt_FromLong(sta);
  271. }
  272. static char gpib_interface_clear__doc__[] =
  273. "interface_clear -- perform interface clear (board)\n"
  274. "interface_clear(handle)";
  275. static PyObject* gpib_interface_clear(PyObject *self, PyObject *args)
  276. {
  277. int device;
  278. int sta;
  279. if (!PyArg_ParseTuple(args, "i:interface_clear", &device))
  280. return NULL;
  281. sta = ibsic(device);
  282. if ( sta & ERR){
  283. _SetGpibError("interface_clear");
  284. return NULL;
  285. }
  286. return PyInt_FromLong(sta);
  287. }
  288. static char gpib_close__doc__[] =
  289. "close -- close descriptor (board or device)\n"
  290. "close(handle)";
  291. static PyObject* gpib_close(PyObject *self, PyObject *args)
  292. {
  293. int device;
  294. int sta;
  295. if (!PyArg_ParseTuple(args, "i:close", &device))
  296. return NULL;
  297. sta = ibonl(device, 0);
  298. if( sta & ERR ){
  299. _SetGpibError("close");
  300. return NULL;
  301. }
  302. return PyInt_FromLong(sta);
  303. }
  304. static char gpib_wait__doc__[] =
  305. "wait -- wait for event (board or device)\n"
  306. "wait(handle, mask)";
  307. static PyObject* gpib_wait(PyObject *self, PyObject *args)
  308. {
  309. int device;
  310. int mask;
  311. int sta;
  312. if (!PyArg_ParseTuple(args, "ii:wait", &device, &mask))
  313. return NULL;
  314. sta = ibwait(device, mask);
  315. if(sta & ERR) {
  316. _SetGpibError("wait");
  317. return NULL;
  318. }
  319. return PyInt_FromLong(sta);
  320. }
  321. static char gpib_timeout__doc__[] =
  322. "timeout -- adjust io timeout (board or device)\n"
  323. "timeout(handle, timeout)\n\n"
  324. "timeout should be one of the symbolic constants TNONE to T1000s";
  325. static PyObject* gpib_timeout(PyObject *self, PyObject *args)
  326. {
  327. int device;
  328. int value;
  329. int sta;
  330. if (!PyArg_ParseTuple(args, "ii:timeout", &device,&value))
  331. return NULL;
  332. sta = ibtmo(device, value);
  333. if( sta & ERR){
  334. _SetGpibError("tmo");
  335. return NULL;
  336. }
  337. return PyInt_FromLong(sta);
  338. }
  339. static char gpib_serial_poll__doc__[] =
  340. "serial_poll -- conduct serial poll (device)\n"
  341. "serial_poll(handle) -> status_byte";
  342. static PyObject* gpib_serial_poll(PyObject *self, PyObject *args)
  343. {
  344. int device;
  345. char spr;
  346. if (!PyArg_ParseTuple(args, "i:serial_poll", &device))
  347. return NULL;
  348. if( ibrsp(device, &spr) & ERR){
  349. _SetGpibError("serial_poll");
  350. return NULL;
  351. }
  352. return Py_BuildValue("c", spr);
  353. }
  354. static char gpib_trigger__doc__[] =
  355. "trigger -- trigger device (device)\n"
  356. "trigger(handle)";
  357. static PyObject* gpib_trigger(PyObject *self, PyObject *args)
  358. {
  359. int device;
  360. int sta;
  361. if (!PyArg_ParseTuple(args, "i:trigger", &device))
  362. return NULL;
  363. sta = ibtrg(device);
  364. if( sta & ERR){
  365. _SetGpibError("trg");
  366. return NULL;
  367. }
  368. return PyInt_FromLong(sta);
  369. }
  370. static char gpib_ibsta__doc__[] =
  371. "ibsta -- retrieve status\n"
  372. "ibsta()";
  373. static PyObject* gpib_ibsta(PyObject *self, PyObject *args)
  374. {
  375. return PyInt_FromLong(ThreadIbsta());
  376. }
  377. static char gpib_ibcnt__doc__[] =
  378. "ibcnt -- retrieve number of bytes transferred\n"
  379. "ibcnt()";
  380. static PyObject* gpib_ibcnt(PyObject *self, PyObject *args)
  381. {
  382. return PyInt_FromLong(ThreadIbcntl());
  383. }
  384. /* List of methods defined in the module */
  385. static struct PyMethodDef gpib_methods[] = {
  386. {"find", gpib_find, METH_VARARGS, gpib_find__doc__},
  387. {"ask", gpib_ask, METH_VARARGS, gpib_ask__doc__},
  388. {"dev", gpib_dev, METH_VARARGS, gpib_dev__doc__},
  389. {"config", gpib_config, METH_VARARGS, gpib_config__doc__},
  390. {"listener", gpib_listener, METH_VARARGS, gpib_listener__doc__},
  391. {"read", gpib_read, METH_VARARGS, gpib_read__doc__},
  392. {"write", gpib_write, METH_VARARGS, gpib_write__doc__},
  393. {"write_async", gpib_write_async, METH_VARARGS, gpib_write_async__doc__},
  394. {"command", gpib_command, METH_VARARGS, gpib_command__doc__},
  395. {"remote_enable", gpib_remote_enable, METH_VARARGS, gpib_remote_enable__doc__},
  396. {"clear", gpib_clear, METH_VARARGS, gpib_clear__doc__},
  397. {"interface_clear", gpib_interface_clear, METH_VARARGS, gpib_interface_clear__doc__},
  398. {"close", gpib_close, METH_VARARGS, gpib_close__doc__},
  399. {"wait", gpib_wait, METH_VARARGS, gpib_wait__doc__},
  400. {"timeout", gpib_timeout, METH_VARARGS, gpib_timeout__doc__},
  401. {"serial_poll", gpib_serial_poll, METH_VARARGS, gpib_serial_poll__doc__},
  402. {"trigger", gpib_trigger, METH_VARARGS, gpib_trigger__doc__},
  403. {"ibsta", gpib_ibsta, METH_NOARGS, gpib_ibsta__doc__},
  404. {"ibcnt", gpib_ibcnt, METH_NOARGS, gpib_ibcnt__doc__},
  405. {NULL, NULL} /* sentinel */
  406. };
  407. /* Initialization function for the module (*must* be called initgpib) */
  408. static char gpib_module_documentation[] =
  409. "This module is a thin wrapper around the Linux GPIB C library.\n"
  410. "Documentation for the C library is available at:\n"
  411. " http://linux-gpib.sourceforge.net\n\n"
  412. "As in the C API, all functions return the value of ibsta,\n"
  413. "except where otherwise specified.";
  414. void initgpib(void)
  415. {
  416. PyObject *m;
  417. /* Create the module and add the functions */
  418. m = Py_InitModule4("gpib", gpib_methods, gpib_module_documentation,
  419. (PyObject*)NULL, PYTHON_API_VERSION);
  420. /* Add GpibError exception to the module */
  421. GpibError = PyErr_NewException("gpib.GpibError", NULL, NULL);
  422. PyModule_AddObject(m, "GpibError", GpibError);
  423. /* Add some symbolic constants to the module */
  424. /* timeout values */
  425. PyModule_AddIntConstant(m, "TNONE", TNONE);
  426. PyModule_AddIntConstant(m, "T10us", T10us);
  427. PyModule_AddIntConstant(m, "T30us", T30us);
  428. PyModule_AddIntConstant(m, "T100us", T100us);
  429. PyModule_AddIntConstant(m, "T300us", T300us);
  430. PyModule_AddIntConstant(m, "T1ms", T1ms);
  431. PyModule_AddIntConstant(m, "T3ms", T3ms);
  432. PyModule_AddIntConstant(m, "T10ms", T10ms);
  433. PyModule_AddIntConstant(m, "T30ms", T30ms);
  434. PyModule_AddIntConstant(m, "T100ms", T100ms);
  435. PyModule_AddIntConstant(m, "T300ms", T300ms);
  436. PyModule_AddIntConstant(m, "T1s", T1s);
  437. PyModule_AddIntConstant(m, "T3s", T3s);
  438. PyModule_AddIntConstant(m, "T10s", T10s);
  439. PyModule_AddIntConstant(m, "T30s", T30s);
  440. PyModule_AddIntConstant(m, "T100s", T100s);
  441. PyModule_AddIntConstant(m, "T300s", T300s);
  442. PyModule_AddIntConstant(m, "T1000s", T1000s);
  443. /* ibconfig() option values */
  444. PyModule_AddIntConstant(m, "IbcPAD", IbcPAD);
  445. PyModule_AddIntConstant(m, "IbcSAD", IbcSAD);
  446. PyModule_AddIntConstant(m, "IbcTMO", IbcTMO);
  447. PyModule_AddIntConstant(m, "IbcEOT", IbcEOT);
  448. PyModule_AddIntConstant(m, "IbcPPC", IbcPPC);
  449. PyModule_AddIntConstant(m, "IbcREADDR", IbcREADDR);
  450. PyModule_AddIntConstant(m, "IbcAUTOPOLL", IbcAUTOPOLL);
  451. PyModule_AddIntConstant(m, "IbcCICPROT", IbcCICPROT);
  452. PyModule_AddIntConstant(m, "IbcSC", IbcSC);
  453. PyModule_AddIntConstant(m, "IbcSRE", IbcSRE);
  454. PyModule_AddIntConstant(m, "IbcEOSrd", IbcEOSrd);
  455. PyModule_AddIntConstant(m, "IbcEOSwrt", IbcEOSwrt);
  456. PyModule_AddIntConstant(m, "IbcEOScmp", IbcEOScmp);
  457. PyModule_AddIntConstant(m, "IbcEOSchar", IbcEOSchar);
  458. PyModule_AddIntConstant(m, "IbcPP2", IbcPP2);
  459. PyModule_AddIntConstant(m, "IbcTIMING", IbcTIMING);
  460. PyModule_AddIntConstant(m, "IbcReadAdjust", IbcReadAdjust);
  461. PyModule_AddIntConstant(m, "IbcWriteAdjust", IbcWriteAdjust);
  462. PyModule_AddIntConstant(m, "IbcEventQueue", IbcEventQueue);
  463. PyModule_AddIntConstant(m, "IbcSPollBit", IbcSPollBit);
  464. PyModule_AddIntConstant(m, "IbcSendLLO", IbcSendLLO);
  465. PyModule_AddIntConstant(m, "IbcSPollTime", IbcSPollTime);
  466. PyModule_AddIntConstant(m, "IbcPPollTime", IbcPPollTime);
  467. PyModule_AddIntConstant(m, "IbcEndBitIsNormal", IbcEndBitIsNormal);
  468. PyModule_AddIntConstant(m, "IbcUnAddr", IbcUnAddr);
  469. PyModule_AddIntConstant(m, "IbcHSCableLength", IbcHSCableLength);
  470. PyModule_AddIntConstant(m, "IbcIst", IbcIst);
  471. PyModule_AddIntConstant(m, "IbcRsv", IbcRsv);
  472. PyModule_AddIntConstant(m, "IbcBNA", IbcBNA);
  473. /* ibask() option values */
  474. PyModule_AddIntConstant(m, "IbaPAD", IbaPAD);
  475. PyModule_AddIntConstant(m, "IbaSAD", IbaSAD);
  476. PyModule_AddIntConstant(m, "IbaTMO", IbaTMO);
  477. PyModule_AddIntConstant(m, "IbaEOT", IbaEOT);
  478. PyModule_AddIntConstant(m, "IbaPPC", IbaPPC);
  479. PyModule_AddIntConstant(m, "IbaREADDR", IbaREADDR);
  480. PyModule_AddIntConstant(m, "IbaAUTOPOLL", IbaAUTOPOLL);
  481. PyModule_AddIntConstant(m, "IbaCICPROT", IbaCICPROT);
  482. PyModule_AddIntConstant(m, "IbaSC", IbaSC);
  483. PyModule_AddIntConstant(m, "IbaSRE", IbaSRE);
  484. PyModule_AddIntConstant(m, "IbaEOSrd", IbaEOSrd);
  485. PyModule_AddIntConstant(m, "IbaEOSwrt", IbaEOSwrt);
  486. PyModule_AddIntConstant(m, "IbaEOScmp", IbaEOScmp);
  487. PyModule_AddIntConstant(m, "IbaEOSchar", IbaEOSchar);
  488. PyModule_AddIntConstant(m, "IbaPP2", IbaPP2);
  489. PyModule_AddIntConstant(m, "IbaTIMING", IbaTIMING);
  490. PyModule_AddIntConstant(m, "IbaReadAdjust", IbaReadAdjust);
  491. PyModule_AddIntConstant(m, "IbaWriteAdjust", IbaWriteAdjust);
  492. PyModule_AddIntConstant(m, "IbaEventQueue", IbaEventQueue);
  493. PyModule_AddIntConstant(m, "IbaSPollBit", IbaSPollBit);
  494. PyModule_AddIntConstant(m, "IbaSendLLO", IbaSendLLO);
  495. PyModule_AddIntConstant(m, "IbaSPollTime", IbaSPollTime);
  496. PyModule_AddIntConstant(m, "IbaPPollTime", IbaPPollTime);
  497. PyModule_AddIntConstant(m, "IbaEndBitIsNormal", IbaEndBitIsNormal);
  498. PyModule_AddIntConstant(m, "IbaUnAddr", IbaUnAddr);
  499. PyModule_AddIntConstant(m, "IbaHSCableLength", IbaHSCableLength);
  500. PyModule_AddIntConstant(m, "IbaIst", IbaIst);
  501. PyModule_AddIntConstant(m, "IbaRsv", IbaRsv);
  502. PyModule_AddIntConstant(m, "IbaBNA", IbaBNA);
  503. PyModule_AddIntConstant(m, "Iba7BitEOS", Iba7BitEOS);
  504. /* Check for errors */
  505. if (PyErr_Occurred())
  506. Py_FatalError("can't initialize module gpib");
  507. }