This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Packet sniffer

Other Parts Discussed in Thread: CC2540

Hello,

I am using a cc2540 mini dev kit, and the Texas Instrument packet sniffer.

I 'd like to know if it is possible to export the RSSI values given by the software (to a spreadsheet for example)?

I have searched  on the forum and I couldn't find a answer

Thank you !!

Emmanuel

  • Hi,

    There is no such export tool in the Packet sniffer today, however you can save the log to a .psd file. The .psd file format is binary and its content explained in section 5 of  the Packet Sniffer User's Guide (SWRU187). It should not be too difficult to make a script that extracts the RSSI value (first byte of the FCS field) to e.g. a .cvs file.

    The .psd files are little endian (that is 0x12345678 is written {0x78, 0x56, 0x34, 0x12} in the .psd file).

    The number of bytes allocated for each packet in the .psd file is constant and depends on the protocol selected. There are two ways to figure out this constant.

    1. Look at the binary file directly and do some pattern recognition based on the psd file packet format.
    2. Look in the ble.plt file located in the "ble" subfolder of <install dir>\SmartRF Tools\Packet Sniffer\bin\general\plugin\ 
      The number of bytes allocated for each packet is Packet_length_raw_data + 1. For BLE you get 270+1.

    For other protocols, e.g. RF4CE, you would look at the rf4ce.plt file located in the "rf4ce" subfolder of the aforementioned folder.

    Hope this helps!

    Br,
    ABO

    --
    PS. Thank you for clicking  Verify Answer  if this answered your question!

  • Thank you for your answer,

    I will try to use these methods and I will tell you if I succeed

    BR

    Emmanuel

  • I have tried the solution proposed by ABO and it works well

    I have used MATLAB to read the.psd file and make a script that extract the RSSI values

    Thank you again

    Emmanuel

  • Hi Emmanuel,

    If you are willing to, you can post this script for use by other members of this community.

    And also write a little how to for the script of yours (if you have the time of course).

    Thank you in advance

  • Hi Igor,

    No problem, I will post it as soon as possible (probably tomorow)

    BR

  • Here is my script,

    It extract the values of RSSI to a spreadsheet using MATLAB.

    I am not specialized in programming so it is very basic, but it works for me

    a=fopen('D:\test1.psd');
    Data=fread(a);
    fclose('all');
    N=numel(Data);
    k=zeros(N,1);
    i=41;
    j=1;
    compteur=0;

    while i<N,                       
        if Data(i)~=0
           k(j)=Data(i);
           i=i+271;
           j=j+1;
           compteur=compteur+1;
     
             end
        
    end



    results=zeros(compteur,1);
    h=1;

    while k(h)~=0,
        
        results(h)=k(h)-94;
        h=h+1;
        
    end

    results

    xlswrite('D:\Mesures1.xls',results)

    BR

    Emmanuel

  • Emmanuel PAPON said:

    Here is my script,

    It extract the values of RSSI to a spreadsheet using MATLAB.

    I am not specialized in programming so it is very basic, but it works for me

    a=fopen('D:\test1.psd');
    Data=fread(a);
    fclose('all');
    N=numel(Data);
    k=zeros(N,1);
    i=41;
    j=1;
    compteur=0;

    while i<N,                       
        if Data(i)~=0
           k(j)=Data(i);
           i=i+271;
           j=j+1;
           compteur=compteur+1;
     
             end
        
    end



    results=zeros(compteur,1);
    h=1;

    while k(h)~=0,
        
        results(h)=k(h)-94;
        h=h+1;
        
    end

    results

    xlswrite('D:\Mesures1.xls',results)

    BR

    Emmanuel

     

    i have tried using this script and it does gives me a list of values (the correct number also) however they are all the same and do no match those that are in the actual in the psd file. I don't no where i am going wrong as i have no done programming beofre. could anybody help me. where are the i, j values coming from, or the -94? I appreciate any help

     

  • Hello,

    I was working with sniffer and I wrote my own Matlab code. Well, I built the code for my application so it is application specific. However, you can eassily modify it. My MATLAB code gives output as Excel file which lists the RSSI, time stamps etc. It also shows if the packet belongs to Master or Slave. The idea is locating the sniffer very close to the slave so that the RSSI is around -35 dbm for slave packets and less for Master. You can also set deciding threshold. I hope it works for you but please ask me if you have questions. My code is quite easy to read. Well at least I did my best :)

    You should work with sniffer_with_role.m. Just change the input .psd file name.6036.Matlab.zip

    Regards, 

  • This is extremely helpful thank you very much. I am having problems with this part of the code

    [A total_num_of_bits]=fread(fid, inf,'*ubit1','ieee-le'); fclose(fid);

    and getting this error

    Error using fread Invalid file identifier.  Use fopen to generate a valid file identifier.  

    i appreciate your help

  • It is because, the code does not see the input .psd file.

    Did you change the input file name? Is your psd file in the same MATLAB working folder with the code? I am sure it is input file error. 

    % PSD Input File Name
    filename='1m.psd';
    filename_output='loc1_out.xls';

    So you should write your psd file name by renaming the value of the variable "filename". 

  • I had the filename changed to suit yes. The file however wasn't in the same folder so this helped however it is now saying the byte2num function is undefined for 'input arguments of type 'cell''? Also the filename output, is this an excek document you have previously created?

  • Hi, you should unzip the zip file in the same folder which means putting all the functions inside the zip file in the same MATLAB working folder. The sniffer_with_role.m is your main function to run. The rest of .m files are functiosa that are used inside the main function. Hence, they all should be in the same folder. Filename output is the name of the output excel file that will be generated after running the code succesfully. Hence, you don't need to create previously.

    Hope it works now

  • Hello All,

    This looks to be a very interesting tool. Anyone has a similar one to extract data from the psd file? Or if I want to modify the current matlab code, where should I do those modifications? I am interested in extracting all the data which I receive as notifications from CC2540 BLE device.

    Thanks so much!

  • Hi,

    It is possible to read all the information of psd files since they are binary files. What you should do is using a binary viewer program and read the documentation of both spec and sniffer manual. I wrote an unofficial guide about how I wrote MATLAB code for my supervisor. Since it is not official paper I did not care about referencing the sources but I used mostly TI documents. I believe the code I attached previously is easy to modify. I can help you for further questions.

    I attached the pdf of my guide report.

    Good luck!

    0654.Reading the Output of Packet Sniffer.pdf

  • Hello,

    You might be interested in looking at this thread where a community member has converted the psd format to PCAP for Wireshark support.

    http://e2e.ti.com/support/low_power_rf/f/155/t/56980.aspx

    LPRF Rocks the World

  • Hi,

    Once i run the code, the following error occurs

    Error in sniffer_with_role (line 324)
    XLS_cells=[ {'Connection Interval: (milliseconds)'}, {conn_interval}, {''},{''},
    {''},{''},{''},{''},{''},{''},{''},{''},{''},{''};...

    Please help me