Error 7 when adding id=2 (Block too large)

Post here to get support
Post Reply
sAz
Beginner
Posts: 7
Joined: Wed Jun 10, 2020 5:35 pm

Error 7 when adding id=2 (Block too large)

Post by sAz »

Hi everyone,

I get the message

Code: Select all

 Error 7 when adding id=2 (Block too large)
every time I try to log the following data:

Code: Select all

lg_vars = {
        'drone.id' : 'uint32_t',
        'drone.psX' : 'float' ,
        'drone.psY' : 'float',
        'drone.psZ' : 'float',
        'drone.esPsX' : 'float',
        'drone.esPsY' : 'float',
        'drone.esPsZ' : 'float'
    }
but when I log the following data it works

Code: Select all

lg_vars = {
        'drone.id' : 'uint32_t',
        'drone.psX' : 'float' ,
        'drone.psY' : 'float',
        'drone.psZ' : 'float'
        }
Is the there a max amount of variables/data that can be logged?
kimberly
Bitcraze
Posts: 704
Joined: Fri Jul 06, 2018 11:13 am

Re: Error 7 when adding id=2 (Block too large)

Post by kimberly »

Hi! There is indeed a limit, as noted here in the documentation. There is a limit of 32 bytes.

A float is 4 bytes and a uint32 as well, so you are supposed to be able to add one more... it might be a bug but you are adding the log variables in kind of a unconventional way. Are you using the cflib python library or is this in crazyswarm?
sAz
Beginner
Posts: 7
Joined: Wed Jun 10, 2020 5:35 pm

Re: Error 7 when adding id=2 (Block too large)

Post by sAz »

For logging I do the following:

Code: Select all

uris = [ 
   'radio://0/80/2M/E7E7E7E7E0',
   'radio://0/80/2M/E7E7E7E7E1',
   'radio://0/80/2M/E7E7E7E7E2'
   ]


def log_stab_callback(uri, timestamp, data, log_conf):
        global recording_pos_dict
        global recording_pos_dict_est
        x = float(data['drone.psX'])
        y = float(data['drone.psY'])
        z = float(data['drone.psZ'])
        est_x = float(data['drone.esPsX'])
        est_y = float(data['drone.esPsY'])
        est_z = float(data['drone.esPsZ'])
        pos_arr = [x, y, z]
        est_pos_arr = [est_x, est_y, est_z]
        recording_pos_dict[uri[-1]].append(pos_arr)
        recording_pos_dict_est[uri[-1]].append(est_pos_arr)
            
            

def simple_log_async(scf):
    lg_vars = {
        'drone.id' : 'uint32_t',
        'drone.psX' : 'float' ,
        'drone.psY' : 'float',
        'drone.psZ' : 'float',
        'drone.esPsX' : 'float',
        'drone.esPsY' : 'float',
        'drone.esPsZ' : 'float'
    }

    lg_stab = LogConfig(name='Position', period_in_ms=100)
    for key in lg_vars:
        lg_stab.add_variable(key, lg_vars[key])

    cf = scf.cf
    cf.log.add_config(lg_stab)
    lg_stab.data_received_cb.add_callback(lambda t, d, l: log_stab_callback(cf.link_uri, t, d, l))
    lg_stab.start()
    time.sleep(0.1)

if __name__ == '__main__':
        cflib.crtp.init_drivers(enable_debug_driver=False) # initialize drivers
        factory = CachedCfFactory(rw_cache='./cache')

        with Swarm(uris, factory=factory) as swarm:
                         swarm.parallel(simple_log_async)
                         
                         while True:
                         
                         ...

Can you please tell me what do you mean by "unconventional way"? To set up everything I have followed the instructions in this link https://www.bitcraze.io/documentation/r ... log_param/ and got some help in the forum

I am using the cflib python library
kimberly
Bitcraze
Posts: 704
Joined: Fri Jul 06, 2018 11:13 am

Re: Error 7 when adding id=2 (Block too large)

Post by kimberly »

Sorry, it is a bit difficult from the first forum post to see how the logs have been added from just the code snippet but it is indeed how it supposed to be done.

I double checked and the maximum is not 32 bytes but 26 bytes since it needs some bytes to patch the packet with more information about the type of packet you are sending. That means that you are supposed to see that error since your logblock consists of 28 bytes.

We saw that this was not super clear in the documentation so currently we are changing this here and here so that this limit is more clear to everybody.

It is possible to create multiple logblocks by the way. It is just that then those logged variables are not exactly timestamped on the same time, but for most applications this should be fine.
Post Reply