sparkfun / Qwiic_Ublox_Gps_Py

https://qwiic-ublox-gps-py.readthedocs.io/en/latest/index.html
Other
69 stars 41 forks source link

Example 5 producing error, object has no attribute "ubx_get_set_del" #16

Open j0npas opened 3 years ago

j0npas commented 3 years ago

ubx_get_val exists in ublox_gps.py but not ubx_get_set_del. Would be helpful to have this example work, unless I'm doing something wrong...

tinchjonathan commented 2 years ago

I'm having the same problem. Any advice would be extremely helpful.

jacklu333333 commented 1 year ago

Hi guys, Since the participants are just you two, I guess SaprkFun doesn't plan to solve in a short time. I found the function in old commit. However, I am not sure the code is validate or not.

def ubx_get_set_del(self, key):

        key_bytes = bytes([])
        if type(key) != bytes:
            while key > 0: 
                key_bytes = key_bytes + bytes([(key & 0xFF)])
                key = key >> 8 

        key_bytes = key_bytes[::-1]
        msg = self.send_message(sp.CFG_CLS, 0x8b, key_bytes)
        parse_tool = core.Parser([sp.CFG_CLS, sp.ACK_CLS])
        msg = parse_tool.receive_from(self.hard_port) 
        return(msg)

Hope this will somehow helps

Best Regards, Jack Lu

j0npas commented 1 year ago

Hi guys, Since the participants are just you two, I guess SaprkFun doesn't plan to solve in a short time. I found the function in old commit. However, I am not sure the code is validate or not.

def ubx_get_set_del(self, key):

        key_bytes = bytes([])
        if type(key) != bytes:
            while key > 0: 
                key_bytes = key_bytes + bytes([(key & 0xFF)])
                key = key >> 8 

        key_bytes = key_bytes[::-1]
        msg = self.send_message(sp.CFG_CLS, 0x8b, key_bytes)
        parse_tool = core.Parser([sp.CFG_CLS, sp.ACK_CLS])
        msg = parse_tool.receive_from(self.hard_port) 
        return(msg)

Hope this will somehow helps

Best Regards, Jack Lu

Thanks for suggesting this, Jack. I'll be getting back into Ublox stuff shortly and I'll give it a try. I appreciate the help!

smithan7 commented 1 year ago

Adding that function into ublox_gps.py allows example 5 to run. However, it is very similar to the ublox_gps.py function "get_val" shown below: def ubx_get_val(self, key_id): """ This function takes the given key id and breakes it into individual bytes which are then cocantenated together. This payload is then sent along with the CFG Class and VALGET Message ID to send_message(). Ublox Messages are then parsed for the requested values or a NAK signifying a problem.

    :return: The requested payload or a NAK on failure.
    :rtype: namedtuple
    """
    key_id_bytes = bytes([])
    if type(key_id) != bytes:
        while key_id > 0:
            key_id_bytes = key_id_bytes + bytes([(key_id & 0xFF)])
            key_id = key_id >> 8

    key_id_bytes = key_id_bytes[::-1]
    msg = self.send_message(sp.CFG_CLS, self.cfg_ms.get('VALGET'), key_id_bytes)
    parse_tool = core.Parser([sp.CFG_CLS, sp.ACK_CLS])
    msg = parse_tool.receive_from(self.hard_port)
    return msg

When I run them both side by side with the same key, I get the same output:

get_val: ('ACK', 'NAK', NAK(clsID=6, msgID=139)) get_set_del: ('ACK', 'NAK', NAK(clsID=6, msgID=139))

However, if I change the msg key to 0x30210001 for CFG-RATE-MEAS I still get:

get_val: ('ACK', 'NAK', NAK(clsID=6, msgID=139)) get_set_del: ('ACK', 'NAK', NAK(clsID=6, msgID=139))

which was surprising - I expected them to be different unless this is some type of error msg?

It's also not obvious how to use this to update the CFG-RATE-MEAS

jacklu333333 commented 1 year ago

@smithan7, I would suggest use pyubx2. It is relatively robust.

Hope this will help you

Best Regards, Jack Lu