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