02-04-2015 06:42 AM
I would like to implement a protocol on a FTDI chip, I would like to discuss the best architecture to use taking into account communication time and Labview efficiency.
The protocol compose of some initial bytes then some data or commands, then the device will reply back with some format which will be some initial bytes then some data or command OK/Error.
Now I was thinking on flashing the interface send command and then wait for X number the bytes in comm buffer and then read the whole block. There is an issue on the current FTDI labview driver as if I don’t close the interface and only pass the handler number to a VI called “FT_Get_Queue_Status” It does return always the same number regardless the bytes at the buffer.
I can foresee another way which would be keep reading x number of bytes at the time and keep checking against the protocol.
Thank you for any help on here.
02-05-2015 03:24 AM
Hi,
I would suggest polling the number of bytes at the port and if it's a whole block then you could perform the read.
I would suggest using a data / consumer architecture using queues to pass the data between them as the seperate loops will be on different threads.
What have you got so far ?
02-05-2015 05:15 AM
@Lucas. wrote:
I would suggest polling the number of bytes at the port and if it's a whole block then you could perform the read.
I was planning to do, send command to FTDI then perform a "read", pass the number of bytes to read to a "read VI" and in there loop to keep running until the buffer (buffer_queue_read VI) the number of bytes decired (with a timer) and when that is reach the whole block then perform a read.
But I may have to modiffied my code as I was openinge port send command then close port, next the read open the port pass the handler to read queue loop and then pass the handler to read and perform a read. But I that Queue_buffer VI does not work very well as when the buffere is enty it keep return a value.
@Lucas. wrote:
I would suggest using a data / consumer architecture using queues to pass the data between them as the seperate loops will be on different threads.
I havent gone into this architerture as I send and read data ( what is setted into the divice) but there is not stream of data coming back from the divice.
02-05-2015 05:53 AM
I'm assuming here that you're using serial communications (e.g. RS-232) - can you not just use the device in Virtual COM Port (VCP) mode and then use the LabVIEW VISA commands for reading/writing to the device? Generally makes things simpler and means that you can use any USB to Serial converter or built-in serial port with your application.