Files
@ 8e2d456b3612
Branch filter:
Location: light9/dmx_usb_module/dmx.pyx - annotation
8e2d456b3612
770 B
text/x-cython
fix some stats and logging
Ignore-this: d5ed651e17695eaea4e599d5dfaf3b0a
Ignore-this: d5ed651e17695eaea4e599d5dfaf3b0a
4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 295e803f6a5e 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 4e60444605f6 295e803f6a5e 4e60444605f6 4e60444605f6 4e60444605f6 | cdef extern from "fcntl.h":
int open(char *pathname, int flags)
int O_WRONLY
cdef extern from "unistd.h":
int write(int fd, void *buf, int count)
cdef extern from "string.h":
char *strncpy(char *dest, char *src, int n)
cdef extern from "Python.h":
char* PyString_AsString(object string)
cdef class Dmx:
cdef int fd
def __cinit__(self, port="/dev/dmx0"):
self.fd = open(port, O_WRONLY)
if self.fd < 0:
raise OSError("open failed")
def write(self, buf):
cdef char *cbuf
cbuf = PyString_AsString(buf)
if cbuf == NULL:
raise ValueError("string buffer conversion failed")
res = write(self.fd, cbuf, 513)
if res < 0:
raise OSError("write failed")
|