def _on_send_cfg_msg(self, *args, **kwargs): # pylint: disable=unused-argument """ CFG-MSG command send button has been clicked. """ msg = key_from_val(UBX_CONFIG_MESSAGES, self._cfg_msg_command) msgClass = int.from_bytes(msg[0:1], "little", signed=False) msgID = int.from_bytes(msg[1:2], "little", signed=False) rateDDC = int(self._ddc_rate.get()) rateUART1 = int(self._uart1_rate.get()) rateUSB = int(self._usb_rate.get()) rateSPI = int(self._spi_rate.get()) data = UBXMessage( "CFG", "CFG-MSG", SET, msgClass=msgClass, msgID=msgID, rateDDC=rateDDC, rateUART1=rateUART1, rateUSB=rateUSB, rateSPI=rateSPI, ) self.__app.serial_handler.serial_write(data.serialize()) self._lbl_send_command.config(image=self._img_pending) self.__container.set_status("CFG-MSG SET message sent", "green") self.__container.set_pending(UBX_CFGMSG, ("ACK-ACK", "ACK-NAK")) self._do_poll_msg(msg)
def msgstr2bytes(msgClass: str, msgID: str) -> bytes: """ Convert plain text UBX message class to bytes e.g. 'CFG-MSG' to b'/x06/x01'. :param str msgClass :param str msgID :return message class as bytes :rtype bytes :raise UBXMessageError """ try: clsid = key_from_val(ubt.UBX_CLASSES, msgClass) msgid = key_from_val(ubt.UBX_MSGIDS, msgID)[1:2] return (clsid, msgid) except KeyError as err: raise ube.UBXMessageError( f"Undefined message, class {msgClass}, id {msgID}") from err
def _on_select_cfg_msg(self, *args, **kwargs): # pylint: disable=unused-argument """ CFG-MSG command has been selected. """ idx = self._lbx_cfg_msg.curselection() self._cfg_msg_command = self._lbx_cfg_msg.get(idx) # poll selected message configuration to get current message rates msg = key_from_val(UBX_CONFIG_MESSAGES, self._cfg_msg_command) self._do_poll_msg(msg)
def testKeyfromVal(self): res = key_from_val(UBX_CLASSES, 'MON') self.assertEqual(res, (b'\x0A'))
def testKeyfromVal(self): res = key_from_val(UBX_CLASSES, "MON") self.assertEqual(res, (b"\x0A"))