From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-05-2007 02:30 PM
03-06-2007 05:50 PM
03-07-2007 08:11 AM
Hi Roland,
NI-Visa 4.0
Jeff
03-07-2007 02:42 PM
Ok,
backed up a step
went into visa interactive mode from the M+A explorer
These are my settings
Timeout Value = 2000
Maximum Queue Length = 50
Termination Character = 0x0A
Termination Char Enable = VI_FALSE
IO Protocol = 1
Suppress End on Reads = VI_FALSE
USB Maximum Interrupt Size = 1
USB Control Pipe = 0x0000
USB Bulk-Out Pipe = 0x0002
USB Bulk-In Pipe = 0x0081
USB Interrupt-In Pipe = 0xFFFF
USB Alternate Setting = 0
USB Bulk-Out Pipe Status = 0
USB Bulk-In Pipe Status = 0
USB Interrupt-In Pipe Status = -1
USB End Mode for Reads = 5
Note that USB interrupt-in pipe=0xffff
From VISA help, it is required that I set it to the bulk in pipe, so I can queue responce when interrrupted.
I cannot change the value of USB Interrup-in pipe to anything other than 0xffff
Need to change it to 0x81, which is bulk in pipe
Get error:
VI_ERROR_NSUP_ATTR_STATE
BFFF001Eh
The specified state of the attribute is not valid, or is not supported as defined by the session, event, or find list.
Is there a bug? Does VISA support interrupt for bulk?
Help
Jeff
03-12-2007 06:38 PM
03-14-2007 08:35 AM
Thanks!
The product we developed only has bulk in and bulk out supported.
Very simple application of usb: simulating a serial port
Packet size is limited, multiple packets sent, sometimes one right after the other.
I started by using the async io functions, but ran into problems when 2 packets were back to back:
The second one was missed consistantly when the async io read was set to get 64 bytes at a time.
When I went to 256 bytes async io read, I sometimes got double read of the first packet, sometimes missed the third packet, unreliable.
There is always some messages coming in, some need to be acknowledged. Felt that interrupt and or queue was the best way to handle.
Without interrupt / queue support, I don't think CVI is going to work for me. I do not think polling will be fast enough as there is no queue. Any suggestions?
I would suggest that you add functionallity to support interrupt or queue or callback on bulk, just like a serial port. I am currently porting over an application that was based on RS232 port to communicate over bulk endpoints on usb. It would be handy, as I could get one application to support multiple modes (TCPIP as well in the future).
Please let me know if I can help. (or if you can help me!)
Thanks,
Jeff Haynes
03-14-2007 07:31 PM
03-15-2007 07:40 AM
Yup,
packet size is 8-64 bytes
there is no end terminator, size embedded inside the packet header
was using async io: did not try readio
Async IO runs in a separate thread, not blocking, event completion using handler
This caused the read problems, closed after each receive io event
read was blocking, don't want to block if possible
read io seemed to have a timeout associated with it,
I did not know that readio queues
Is there any way to know how many bytes are waiting to be read? don't want to call it if there is nothing there,
Thanks,
Jeff
03-15-2007 11:30 AM
03-15-2007 11:56 AM
I'm sorry what I meant to say was that VISA always requests to read a multiple of Max Packet Sized bytes. So if your Max Packet Size is 64 bytes, and you request an 8 byte packet we still try to read 64 bytes. If the device returns 8 bytes then we simply give you the 8 bytes. If the device actually returns 64 bytes (which it is allowed to) then we give you 8 bytes and queue the rest.
Ok,
switched over to VI_READ, timeout is set to several seconds
Yes, I see this activity. I now have something that almost works. I no longer appear to be dropping packets.
Since my packets can be 8-64 bytes long, and multiple payloads from each packet need to be appended together, life is complicated.
There isn't a way to know how many bytes we have in the queue, but if we end up getting more than you asked for from a read we return VI_SUCCESS_MAX_CNT. In my opinion you should avoid this by always asking for what you know the device is going to send.
I do not know the size of the packet ahead of time, so I choose 64
I do not see a way to avoid this, and would be real nice to know if anything is in the queue and how big the queue is.
I handle this case in RS232 land using a callback: When a character is recieved, I find out how many characters in the buffer, and transfer them to local storage until I build a data packet, then process the packet and repeat.
viRead and viReadAsync should both have the same behavior. Except of course that viRead will block, and viReadAsync won't. Both can timeout, but you can always set an infinite timeout.
Investigating this, was doing it viREADASYNC without infinite timeout: gonna try again
If you are using viReadAsync, you will need to handle the VI_EVENT_IO_COMPLETION event, and ensure that you check the status with viGetAttribute on VI_ATTR_STATUS.
Done, but was not checking this: This status is updated when the handler completes and closes the event, correct?
I would also recommend that you simply open a handle to you device, and only close it when you are done and cleaning up.
Done
Thanks NI!
will keep ya posted
Jeff