diff options
Diffstat (limited to 'tests/test2/notes.txt')
-rw-r--r-- | tests/test2/notes.txt | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/test2/notes.txt b/tests/test2/notes.txt new file mode 100644 index 0000000..96a702e --- /dev/null +++ b/tests/test2/notes.txt @@ -0,0 +1,78 @@ + + +ENTTEC OPEN DMX USB + +lsusb | grep FT232 +Bus 004 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC + + +On peut communiquer avec ce périphérique Série via la libftdi + +i libftdi1 - Library to control and program the FTDI USB controller + + +Dans l'ordre : + +#include <time.h> + +static const int VID = 0x0403; //! FTDI Vendor ID +static const int PID = 0x6001; //! FTDI Product ID + +// One "official" DMX frame can take (1s/44Hz) = 22727272ns +#define DMX_FRAMETIME 22727272 +#define DMX_BREAK 110000 +#define DMX_MAB 16000 +#define DMX_CHANNELS 512 + +inline void ts_diffadd(struct timespec *res, struct timespec *a, struct timespec *b, struct timespec *c) { + time_t rem; + + res.tv_nsec=a.tv_nsec-b.tv_nsec+c.tv_nsec; + rem=res.tv_nsec/1e9 + res.tv_nsec=res.tv_nsec%1e9; + res.tv_sec=a.tv_sec-b.tv_sec+c.tv_sec+rem; + + if (res.tv_nsec<0 && res.tv_sec>0) res.tv_sec--; res.tv_nsec+=1e9; + if (res.tv_nsec>0 && res.tv_sec<0) res.tv_nsec-=1e9; res.tv_sec++; +} + + +ftdi_usb_find_all(&ftdi, &list, QLCFTDI::VID, QLCFTDI::PID); + +ftdi_usb_open_desc(&m_handle, QLCFTDI::VID, QLCFTDI::PID, name().toAscii(), serial().toAscii()) +ftdi_usb_reset(&m_handle) +ftdi_set_baudrate(&m_handle, 250000) +ftdi_set_line_property(&m_handle, BITS_8, STOP_BIT_2, NONE) +ftdi_setflowctrl(&m_handle, SIO_DISABLE_FLOW_CTRL) +ftdi_usb_purge_buffers(&m_handle) +ftdi_setrts(&m_handle, 0) + +frame_time.tv_sec=0; +frame_time.tv_nsec=DMX_FRAMETIME; + +// Attente initiale (juste après ouverture periph) +to_sleep.tv_sec=0; +to_sleep.tv_nsec=1e6; +nanosleep(to_sleep,NULL); + + +clock_gettime(CLOCK_MONOTONIC, now); + +ts_diffadd(to_sleep,frame_time,now,trame_begin); +nanosleep(to_sleep); + +clock_gettime(CLOCK_MONOTONIC, trame_begin); +ftdi_set_line_property2(&m_handle, BITS_8, STOP_BIT_2, NONE, BREAK_ON) +usleep(DMX_BREAK); +ftdi_set_line_property2(&m_handle, BITS_8, STOP_BIT_2, NONE, BREAK_OFF) +usleep(DMX_MAB); +m_ftdi->write(m_universe) +ftdi_write_data(&m_handle, m_universe, sizeof(m_universe)) + + + +ftdi_usb_close(&m_handle) + + + +rq : si résultat <0, affichage erreur avec ftdi_get_error_string(&m_handle) |