Hello,
Already sent some emails previously about this issue but had no help at
all, and since I'd really like to have this working, I'm making a second
attempt to figure out if there's someone that could help me out with
this problem.
I have a USB/DMX Interface based on FT232RL chipset, and I'm using
libftdi under linux to write DMX. Basically, for writing I have to
control the timing myself and send the correct breaks at appropriate
times together with the data, if you guys which to check out how the
protocol works (It's quite simple), please check here
http://en.wikipedia.org/wiki/DMX512#Protocol
The procedure to read I'm using is more or less like this:
- open device, reset, set line properties, set baud, set flow ctrl,
purge buffers and then set rts
- then I proceed to check when a break happens with
ftdi_poll_modem_status
- when break happens I dead 513 bytes of data (512 + 1 startbit)
- proceed to purge buffers back to break watching
Now I have no idea if this is the correct procedure to do this task, I
think it's the best one from the limited knowledge I have, as I need to
figure out when the BREAK happens to know when to read the data from the
device, or else the values read won't end up in the right place, but,
I'm having trouble having a consistent reading. For starters the values
aren't in the right place, they still 'shift' around while doing so, and
the break bit in poll modem status is not set so often as it should.
I've been checking some examples with FTD2XX lib from FTDI and they use
more or less the same philosophy, and using that lib with their examples
works properly, this is a snippet of how it's done with FTD2XX:
int i;
int recv_count = 0;
bool wait_for_break = true;
ULONG bytesWritten;
unsigned char data;
static COMSTAT oldCS = {0};
static DWORD dwOldErrors = 0;
COMSTAT newCS;
DWORD dwErrors;
BOOL bChanged = false;
// set RS485 for receive
FT_W32_EscapeCommFunction(ftHandle,SETRTS);
FTTIMEOUTS ftTS;
ftTS.ReadIntervalTimeout = 0;
ftTS.ReadTotalTimeoutMultiplier = 0;
ftTS.ReadTotalTimeoutConstant = 1000;
ftTS.WriteTotalTimeoutMultiplier = 0;
ftTS.WriteTotalTimeoutConstant = 200;
FT_W32_SetCommTimeouts(ftHandle,&ftTS);
DWORD dwMask = EV_ERR;
FT_W32_SetCommMask(ftHandle,dwMask);
DWORD dwEvents;
while (!Terminated) {
FT_W32_WaitCommEvent(ftHandle, &dwEvents, NULL);
FT_W32_ClearCommError(ftHandle, &dwErrors, (FTCOMSTAT *)&newCS);
if (dwErrors != dwOldErrors) {
bChanged = true;
dwOldErrors = dwErrors;
}
if (bChanged) {
if ((dwErrors & CE_BREAK) || (dwErrors & CE_FRAME)) {
FT_W32_ReadFile(ftHandle, &temp_StartCode, 1,
&bytesWritten, NULL);
FT_W32_ReadFile(ftHandle, temp_DMXData, 512,
&bytesWritten, NULL);
Synchronize(UpdateScreen);
}
}
FT_W32_PurgeComm(ftHandle,FT_PURGE_TX | FT_PURGE_RX);
}
Is it possible to do this with libftdi ?! How can I ?
Best regards,
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|