June 15, 2015
An acquisition program using the RingBuffer library must use at least these API calls, in the order shown:
Get the ring buffer fill rate.
Parameters:Get the ring buffer channel fill rate.
Parameters:This is a measured fill rate. If the buffer is being filled from a Usb, this should be close to the actual rate at which the channel is being sampled. If the buffer is being filled from a socket, the rate is determined using the number of channels being transferred, which may be less than the number being sampled remotely. Ideally the client and server channel fill rates should closely match.
ContentsGet library version number and other run parameters as an ASCII string.
Parameters:The string returned in "infoBuffer" is NULL terminated.
ContentsGet a hardware parameter as an ASCII string.
Parameters:The string returned in "infoBuffer" is NULL terminated. If the requested parameter is not available, a 0 length string is returned, i.e. infoBuffer[0] = 0.
ContentsGet the number of channels being sampled.
Parameters:This is the size of a single channel sweep in the ring buffer. If this is a client application taking samples from a socket and the client has requested only a subset of samples be transferred, the sweep size still matches that being used by the server. Channels not transferred are set to x'ffffff00'.
ContentsGet the number of channels being transferred from a remote acquisition.
Parameters:By default, all channels being acquired at the remote Usb are transferred. A reduced number of channels can be requested using the call SET_TRANSFER_CHANNEL_REQUEST_RANGES.
ContentsGet the number of socket re-syncs (re-connects) that have occurred during this run.
Parameters:Re-syncs occur when the socket transmission rate cannot keep up with the Usb acquisition rate. This is usually detected at the serving end and causes the server to close the channel. The client immediately re-connects but some sets of samples are lost to the client. By default, all channels being acquired at the remote Usb are transferred. Reducing the number of channels being transferred should reduce the number of re-syncs. A reduced number of channels can be requested using the call SET_TRANSFER_CHANNEL_REQUEST_RANGES.
ContentsGet the remote ring buffer channel fill rate.
Parameters:This fill rate is measured by the remote application. It should be close to the actual rate at which the channel is being sampled.
ContentsGet the current STRIDE setting being used.
Parameters:STRIDE can be set also using parameters "stride_kb" or "stride_ms" in the "ringbuffer.ini" file or by a call to SET_STRIDE_MS or SET_STRIDE_KB. The default is 131072 bytes.
ContentsGet the current SYNC setting being used.
Parameters:When SYNC is TRUE, READ_POINTER and READ_POINTER_WITH_CYCLE expect position values in the parameters "cycleNum" and "pointer" when called and won't return until the position changes; when SYNC is FALSE, these routines return immediately. When the call doesn't return until there is a position change, the caller doesn't loop burning up CPU time. SYNC can be set on/off also by using parameter "sync" or "nosync" in the "ringbuffer.ini" file or by calling SET_SYNC.
ContentsInitializes the ring buffer support library.
Parameters:The ring buffer can be filled with samples from either
The parameter file "ringbuffer.ini" is read during the first OPEN_DRIVER call only. Parameters set by API calls before that first OPEN are overridden by any corresponding parameters in the file; parameters set after that first OPEN will override anything set by the file.
ContentsCreates a thread to control the acquisition process.
Parameters:Establishes the ring buffer to be used to receive samples during data acquisition. Starts a separate thread to control the acquisition process. The actual flow of samples doesn't start until enabled by a call to USB_WRITE.
The ring buffer can be any size as long as it is a multiple of 512 bytes (Linux and OSX) or a multiple of 4 bytes (Windows).
Because the ring buffer may be undergoing transmission to a remote client via Tcp, the contents of this buffer should not be changed by the user during acquisition.
ContentsDetermines the position in the ring buffer (a byte index) at which new samples are being stored.
Parameters:When the ring buffer is being filled from a socket rather than the Usb, a single FALSE return indicates that a re-sync has occurred; two FALSE returns in a row indicate that acquisition has stopped.
Note: When using sync'ed READ_POINTER calls, "pointer" is an input and output parameter.
ContentsDetermines the cycle and position in the ring buffer (a byte index) at which new samples are being stored.
Parameters:Together "cycleNum" and "pointer" can be used to determine if data overrun has occurred in the ring buffer since the last call. Data overrun is when a complete cycle of the buffer has occurred since the last call. For example, it would be overrun if:
When the ring buffer is being filled from a socket rather than the Usb, a single FALSE return indicates that a re-sync has occurred; two FALSE returns in a row indicate that acquisition has stopped.
Note: When using sync'ed READ_POINTER calls, both "cycleNum" and "pointer" are input and output parameters.
ContentsSet the node and port to connect to if running in client mode.
Parameters:The connect node can be set also using parameter "connect_node" in the "ringbuffer.ini" file. The default is the loopback address, "127.0.0.1".
The connect port can be set also using parameter "connect_port" in the "ringbuffer.ini" file. The default is the "3113".
Setting the connect port to "0" disables any connection attempt.
ContentsSet the port to listen to if running in sample server mode.
Parameters:The listen port can be set also using parameter "listen_port" in the "ringbuffer.ini" file. The default is the "3113".
Setting the listen port to "0" disables listening for client connection attempts.
ContentsSet the STRIDE to be used.
Parameters:STRIDE can be set also using parameters "stride_kb" or "stride_ms" in the "ringbuffer.ini" file or by a call to SET_STRIDE_MS. The default is 131072 bytes.
ContentsSet the STRIDE to be used.
Parameters:STRIDE can be set also using parameters "stride_ms" or "stride_kb" in the "ringbuffer.ini" file or by a call to SET_STRIDE_KB. The default is 131072 bytes.
ContentsSet the SYNC value to be used.
Parameters:When SYNC is TRUE, READ_POINTER and READ_POINTER_WITH_CYCLE expect position values in the parameters "cycleNum" and "pointer" when called and won't return until the position changes; when SYNC is FALSE, these routines return immediately. When the call doesn't return until there is a position change, the caller doesn't loop burning up CPU time.
SYNC can be set on/off also by using parameters "sync" or "nosync" in the "ringbuffer.ini" file. ContentsSet the channels to be transferred by socket from the Usb ring buffer.
Parameters:When the ring buffer is being filled from a socket, channels not transferred are set to x'ffffff00'.
ContentsWrite a 64 byte array to the BioSemi Usb Receiver.
Parameters:The byte array "data" is used to start and stop the flow of samples through the Usb interface and to send trigger outputs:
Sending triggers doesn't work if the program is running as a client, i.e. when its ring buffer is being filled from a Tcp socket.
Download an FX2 EEPROM file using Usb.
Parameters:The file to be downloaded must be called "USB2.iic". It is expected to exist in:
Download an FX2 IIC Firmware file using Usb.
Parameters:The file to be downloaded must be called "Vend_Ax.bix". It is expected to exist in: