Uncomplete profile data from Ping Echosounder

Hello,

I’m using Ping Echosounder. I read in manual that it has to give 200 samples of power measurements, but I only receive amount in range 160 - 194. Can anybody help me to understand this issue?

Greeting,
Bartosz Łarzewski.

Hi @Bartosz,

  1. Which firmware version are you using?
  2. Could you explain (/provide code for) how you’re getting the profile messages?
  3. Are you saying that profile.profile_data_length is changing between pings?

Hello,

  1. I’m using

  2. Here is the code:

from brping import PingParser, PingMessage, Ping1D
import time

sciezka = 'nowy1.txt'

myPing = Ping1D()           # obiekt klasy Ping1D
myMessage = PingMessage()   # obiekt klasy PingMessage
myParser = PingParser()     # obiekt klasy PingParser

myPing.connect_serial("COM4",115200)    # połączenie echosondy z komputerem
myPing.initialize()                     # inicjacja pracy echosondy

myPing.set_mode_auto(0)
myPing.set_ping_interval(200)           # ustawienie przedziału czasowego pomiędzy pomiarami
myPing.set_range(0,3500)
myPing.set_ping_enable(1)
time.sleep(1)

predkosc = myPing.get_speed_of_sound()
print(predkosc)
i = 0

#time.sleep(5)

while True:
    i += 1
    myMessage = myPing.get_profile()            # odczyt profilu danych
    time.sleep(0.2)
    
    dane = myMessage
    print(str(dane))
    
    plik = open(sciezka,'a')      # zapis informacji z otrzymaje ramki
    plik.write(str(myMessage) + "\n")
    plik.close()
    
    
    print(str(i))
    time.sleep(0.5)
    if i == 10:
        break

print("###############################################################")
  1. Here is one measurement, which I received:
 {'distance': 4721, 'confidence': 100, 'transmit_duration': 147, 'ping_number': 1118, 'scan_start': 0, 'scan_length': 5500, 'gain_setting': 1, 'profile_data': b'\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\r\x0eD_];\x18\x07\x05\x05\x05\x06\x06\x06\x05\x04\x00\x00\x01\x04\x05\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x04\x0c\x13\x16\x18\x1a\x10\x05\x01\x03\x07\x07\x07\n\x12\x19\x1f!\x1c\x16\x0b\x01\x06\x17-@NB*\x10\x04\x01\x01\x00\x00\x01\t\x13+Ei{\xa9\xfd\xfd\xfd\xfd\xfd\xfd\xb8\xaa\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfdo\r\x05\x07\xfd\xfd\xfd\xfd\xff\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd'} 

I do not received parameter profile.profile_data_length in upper measurement. It also contains some strange informations like “@NB*” or “D_];” and I do not know how to interpret it.

Sorry for missing, I am using V2.3.4 version.

If I paste that into a Python program, it has 200 data points, as expected:

profile_response =  {'distance': 4721, 'confidence': 100, 'transmit_duration': 147, 'ping_number': 1118, 'scan_start': 0, 'scan_length': 5500, 'gain_setting': 1, 'profile_data': b'\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\r\x0eD_];\x18\x07\x05\x05\x05\x06\x06\x06\x05\x04\x00\x00\x01\x04\x05\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x04\x0c\x13\x16\x18\x1a\x10\x05\x01\x03\x07\x07\x07\n\x12\x19\x1f!\x1c\x16\x0b\x01\x06\x17-@NB*\x10\x04\x01\x01\x00\x00\x01\t\x13+Ei{\xa9\xfd\xfd\xfd\xfd\xfd\xfd\xb8\xaa\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfdo\r\x05\x07\xfd\xfd\xfd\xfd\xff\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd'} 
print(len(profile_response['profile_data'])) # 200

The message sent by the sonar includes a profile_data_length field in order to help with parsing. If you’re using the Ping1D class (instead of parsing the messages manually) then that information isn’t necessary, because it separates out the profile data for you, as a bytes object.

You can use the data values by just indexing from the bytes object, but if you want to see the data numbers from the profile then you can do something like

data_numbers = list(profile_response['profile_data'])
print(data_numbers) # [253, 253, ... 13, 14, 68, ... 253, 253]

Just to make sure you’re aware, the get_speed_of_sound function tells you what the speed of sound is currently set to in the sonar. By default it is set to 1500000 mm/s when the sonar is turned on, but you can change it to a different value with the set_speed_of_sound function if you have a better estimate for your operating conditions :slight_smile:

Your response was so helpful. Thank you so much :slight_smile:

1 Like

Hello,

I have another issue related to obtained data from ping sonar. I save data in text file, it looks like this:

{'distance': 4812  'confidence': 100  'transmit_duration': 147  'ping_number': 51153  'scan_start': 0  'scan_length': 5500  'gain_setting': 0  'profile_data': b'\xa2\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xddG\x16\t\x03\x01\x02\x05\x07\t\n\t\x06\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x03\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x120b\xc3\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd4\x18-8Sq\x93\x9f\xa6\xb1\x9bp\x16\x00\x1cS\x87\x98U1.6<1#&7Na^J$\x10\x02\x00\x00\x00\x02\x05\t\t\x02\x00\x0b"<GE<)\x12\x03\x01\x0c\x1f14$\x13\x07\x02\x01\x01\x01\x01\x02\x02\x03\x05\x06\x05\x04\x02\x00\x00\x00\x00\x00\x00\x00&\xfd\xfd\xfd\xfd\xfd\xfd\xff\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xf3\x90\xfd\xfd\xfd\xfd\xfd'}
{'distance': 4812  'confidence': 100  'transmit_duration': 147  'ping_number': 51157  'scan_start': 0  'scan_length': 5500  'gain_setting': 0  'profile_data': b'\xaa\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xdb:\x0e\x04\x00\x00\x00\x01\x03\x05\x08\x08\x06\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x04\x05\x04\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\r+d\xbf\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfdY)35Ki\x8d\xa4\xb3\xc5\xb0z\x17\x03\x1fQw~C+7IP<(*:Ww\x81rC\x1c\x04\x00\x00\x02\x07\x0f\x19\x1a\r\x01\x02\x14/DJC1\x16\x05\x04\x10\x1f-+\x1c\x0c\x03\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00"\xfc\xfd\xfd\xfd\xfd\xfd\xff\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xf4\xde\xfd\xfd\xfd\xfd\xfd'}
{'distance': 4812  'confidence': 100  'transmit_duration': 147  'ping_number': 51161  'scan_start': 0  'scan_length': 5500  'gain_setting': 0  'profile_data': b'\x8f\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xb92\r\x05\x01\x00\x00\x00\x02\x04\x06\x07\x05\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x04\x05\x06\x05\x03\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x08!S\xa4\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfdN\x1f%&9Rq\x85\x92\xa2\x92e\x12\x03\x1dHio<\'2AE2"#1Hbi]5\x15\x02\x00\x00\x02\x05\r\x15\x16\x0b\x01\x00\r#5:6\'\x11\x03\x03\x0e\x1c((\x1b\x0c\x04\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00!\xdf\xfd\xfd\xfd\xfd\xfd\xff\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xed\xcd\xfd\xfd\xfd\xfd\xfd'}
{'distance': 4812  'confidence': 100  'transmit_duration': 147  'ping_number': 51165  'scan_start': 0  'scan_length': 5500  'gain_setting': 0  'profile_data': b'\xa1\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xd6C\x19\x0f\t\x05\x04\x04\x05\x07\x07\x06\x04\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x05\x06\x06\x05\x03\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x01\x01\x00\x00\x07)j\xd2\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd]\x17\x1c"=\\\x7f\x90\x97\xa2\x8c[\x0b\x06+a\x8a\x97Z@DJF4$&8RmmX+\x0b\x00\x00\x03\x04\x08\x0f\x15\x15\n\x00\x02\x13-?@9&\x0f\x02\x03\x11$79+\x19\x0b\x04\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x03\x01\x00\x00\x00\x00\x035\xfd\xfd\xfd\xfd\xfd\xfd\xff\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xd0\xfd\xfd\xfd\xfd\xfd'}
...

and now I would like to convert it from bytes to integers:

data_numbers = list(profile_response['profile_data'])
print(data_numbers) # [253, 253, ... 13, 14, 68, ... 253, 253]

but during saving data in text file whole data was converted to string datatype and now when I would like to read data from file and convert ‘profile_data’ into integers I can not obtain dictionary again with correct datatypes therein.

The values you’ve shown there should all be treatable as Python objects, so you should be able to do something like

from ast import literal_eval
with open('ping_sonar_data.txt') as file:
    for line in file:
        profile_response = literal_eval(line)
        print(profile_response['profile_data'])

That said, if you’re going to save data like that then I recommend you also include timestamps of the messages together with each message (either as a separate field, or injected into the dictionary output) - it’s generally a useful piece of information to have when you’re later trying to use the data for something meaningful.