Commit | Line | Data |
---|---|---|
bcf4a08b | 1 | /* File: ftdi1.i */ |
4c5afeb9 | 2 | |
bcf4a08b | 3 | %module(docstring="Python interface to libftdi1") ftdi1 |
4c5afeb9 | 4 | |
50280d45 MZ |
5 | %include <typemaps.i> |
6 | %include <cstring.i> | |
f5b59bd6 | 7 | |
05c0dae8 | 8 | %typemap(in) unsigned char* = char*; |
4c5afeb9 | 9 | |
b060307c TJ |
10 | %immutable ftdi_version_info::version_str; |
11 | %immutable ftdi_version_info::snapshot_str; | |
12 | ||
4c5afeb9 | 13 | %rename("%(strip:[ftdi_])s") ""; |
b790d38e | 14 | |
50280d45 MZ |
15 | %newobject ftdi_new; |
16 | %typemap(newfree) struct ftdi_context *ftdi "ftdi_free($1);"; | |
17 | %delobject ftdi_free; | |
18 | ||
19 | %typemap(in,numinputs=0) SWIGTYPE** OUTPUT ($*ltype temp) %{ $1 = &temp; %} | |
20 | %typemap(argout) SWIGTYPE** OUTPUT %{ $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj((void*)*$1,$*descriptor,0)); %} | |
21 | %apply SWIGTYPE** OUTPUT { struct ftdi_device_list **devlist }; | |
22 | int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devlist, | |
23 | int vendor, int product); | |
24 | %clear struct ftdi_device_list **devlist; | |
25 | ||
26 | %apply char *OUTPUT { char * manufacturer, char * description, char * serial }; | |
4c5afeb9 MZ |
27 | %cstring_bounded_output( char * manufacturer, 256 ); |
28 | %cstring_bounded_output( char * description, 256 ); | |
29 | %cstring_bounded_output( char * serial, 256 ); | |
50280d45 | 30 | %typemap(default,noblock=1) int mnf_len, int desc_len, int serial_len { $1 = 256; } |
4c5afeb9 MZ |
31 | int ftdi_usb_get_strings(struct ftdi_context *ftdi, struct libusb_device *dev, |
32 | char * manufacturer, int mnf_len, | |
33 | char * description, int desc_len, | |
34 | char * serial, int serial_len); | |
50280d45 MZ |
35 | %clear char * manufacturer, char * description, char * serial; |
36 | %clear int mnf_len, int desc_len, int serial_len; | |
05c0dae8 | 37 | |
50d77f8f MZ |
38 | %typemap(in,numinputs=1) (unsigned char *buf, int size) %{ $2 = PyInt_AsLong($input);$1 = (unsigned char*)malloc($2*sizeof(char)); %} |
39 | %typemap(argout) (unsigned char *buf, int size) %{ if(result<0) $2=0; $result = SWIG_Python_AppendOutput($result, PyString_FromStringAndSize((char*)$1, $2)); free($1); %} | |
05c0dae8 | 40 | int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size); |
50d77f8f | 41 | %clear (unsigned char *buf, int size); |
f0005c33 | 42 | |
05c0dae8 TH |
43 | %apply int *OUTPUT { unsigned int *chunksize }; |
44 | int ftdi_read_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize); | |
45 | int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize); | |
46 | %clear unsigned int *chunksize; | |
f0005c33 | 47 | |
05c0dae8 TH |
48 | %apply char *OUTPUT { unsigned char *pins }; |
49 | int ftdi_read_pins(struct ftdi_context *ftdi, unsigned char *pins); | |
50 | %clear unsigned char *pins; | |
f0005c33 | 51 | |
05c0dae8 TH |
52 | %apply char *OUTPUT { unsigned char *latency }; |
53 | int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency); | |
f0005c33 TJ |
54 | %clear unsigned char *latency; |
55 | ||
4c5afeb9 | 56 | %apply short *OUTPUT { unsigned short *status }; |
05c0dae8 | 57 | int ftdi_poll_modem_status(struct ftdi_context *ftdi, unsigned short *status); |
f0005c33 TJ |
58 | %clear unsigned short *status; |
59 | ||
4c5afeb9 MZ |
60 | %apply int *OUTPUT { int* value }; |
61 | int ftdi_get_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value value_name, int* value); | |
62 | %clear int* value; | |
f0005c33 | 63 | |
50d77f8f MZ |
64 | %typemap(in,numinputs=1) (unsigned char *buf, int size) %{ $2 = PyInt_AsLong($input);$1 = (unsigned char*)malloc($2*sizeof(char)); %} |
65 | %typemap(argout) (unsigned char *buf, int size) %{ if(result<0) $2=0; $result = SWIG_Python_AppendOutput($result, PyString_FromStringAndSize((char*)$1, $2)); free($1); %} | |
50280d45 | 66 | int ftdi_get_eeprom_buf(struct ftdi_context *ftdi, unsigned char * buf, int size); |
50d77f8f | 67 | %clear (unsigned char *buf, int size); |
50280d45 | 68 | |
4c5afeb9 MZ |
69 | %apply short *OUTPUT { unsigned short *eeprom_val }; |
70 | int ftdi_read_eeprom_location (struct ftdi_context *ftdi, int eeprom_addr, unsigned short *eeprom_val); | |
71 | %clear unsigned short *eeprom_val; | |
f0005c33 | 72 | |
05c0dae8 TH |
73 | %apply int *OUTPUT { unsigned int *chipid }; |
74 | int ftdi_read_chipid(struct ftdi_context *ftdi, unsigned int *chipid); | |
75 | %clear unsigned int *chipid; | |
76 | ||
4c5afeb9 MZ |
77 | %include ftdi.h |
78 | %{ | |
79 | #include <ftdi.h> | |
80 | %} | |
81 | ||
82 | %include ftdi_i.h | |
83 | %{ | |
84 | #include <ftdi_i.h> | |
85 | %} |