C++builder support

Applications, development tools, FPGA, C, WEB
Post Reply
g.feugnet
Posts: 3
Joined: Tue Jul 12, 2016 8:27 am

C++builder support

Post by g.feugnet » Mon Jul 25, 2016 4:21 pm

Hi, I am trying to pilot a Redpitaya from C++builder as I have developed many data analysis tools that I want to apply on data acquired with the RP fast channels.
My pb is with how to retrieve data thru TCP/IP connection (as it is done in the Matlab example.
I am able to establish connection with either the standard TcpClient component provided by Borland/Embarcadero or the Indy IdTcpClient component. I am also able to get the LED flashing as the Matlab example.
However, I don't know how to retrieve acquired data.
Could someone suggest me ideas ?

NB : I think I cannot use the C provided examples as there are written for Linux where an instrument is managed as an device.

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: C++builder support

Post by Nils Roos » Mon Jul 25, 2016 9:12 pm

There's also a Matlab example for acquiring and retrieving samples.

Quoting from this example:

Code: Select all

while 1
    trig_rsp=query(tcpipObj,'ACQ:TRIG:STAT?')

    if strcmp('TD',trig_rsp(1:2))  % Read only TD

    break

    end
end

% Read data from buffer 
signal_str=query(tcpipObj,'ACQ:SOUR1:DATA?');
signal_str_2=query(tcpipObj,'ACQ:SOUR2:DATA?');

% Convert values to numbers.% First character in string is “{“   
% and 2 latest are empty spaces and last is “}”.  

signal_num=str2num(signal_str(1,2:length(signal_str)-3));
signal_num_2=str2num(signal_str_2(1,2:length(signal_str_2)-3));

g.feugnet
Posts: 3
Joined: Tue Jul 12, 2016 8:27 am

Re: C++builder support

Post by g.feugnet » Tue Jul 26, 2016 10:12 am

Thank you for your answer. i saw the example but I could not figure out the equivalent of the Matlab query function that seems to be a high level function encapsulating instrument dialog. For instance, it works also for GPIB instrument. In the C++Builder Indy component, there is an object call IdFinger with a method called query but it seems dedicated to database.
I think the solution might be in the use of the TC/IP RetrieveBuf, RetrieveText .. methods but I am not familiar enough with them

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: C++builder support

Post by Nils Roos » Tue Jul 26, 2016 8:21 pm

Ok, now I understand your problem. All I can say about it is that the query method does not do anything that's specific to the Red Pitaya. Communication between Matlab and the Red Pitaya - the scpi-server running on it, to be precise - is text-based and line-oriented. The only thing that's slightly special is the use of CR/LF line endings.

g.feugnet
Posts: 3
Joined: Tue Jul 12, 2016 8:27 am

Re: C++builder support

Post by g.feugnet » Thu Jul 28, 2016 2:58 pm

Finally, I managed to control the card with Indy component v10.

I used IdTCPClient->Socket->WriteLn to send command. There is no need to add EOL or CR as the Indy WriteLn function takes care of this.

Then I retrieve either the card parameters or the data with a IdTCPClient->Socket->ReadLn instruction.

In order to retrieve the data properly, it is necessary to set MaxLineLength by using the IdTCPClient->IOHandler->MaxLineLenth = BufferSize* 32
where BufferSize is returned by a ACQ:BUF:SIZE request. For the full buffer acquisition, it is 16384 * 32.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 4 guests