Sorry if a lot of this has been asked before, and I will continue to search, but thought I would ask a few questions anyway…
Decided to try to better learn Python and see about converting my Dynamixel servo LLA into an HLA using the the Serial LLA, which makes a lot of sense as I often wanted to see the actual bytes as well as the actual packet information. Besides it is one way to get a better understanding of Python. I am faking my way through it with the help of google.
While I am doing this, I am still fumbling along with a few current questions. Some sort of Python related, some your HLA classes and some how to do similar stuff to LLA.
Questions like:
If I have a something like ChoicesSetting
ChooseServoTypes = ChoicesSetting(
label='Protocol 1 Servo Type',
choices=('AX Servos (default)', 'MX Servos', 'XL 320 Servos', 'X Servos')
)
In order to find the users settings, Do I have to do something like:
if self.ChooseServoTypes == 'AX Servos (default)':
self.prot1TableIndex = 0
elif self.ChooseServoTypes == 'MX Servos':
self.prot1TableIndex = 1
...
Or is there a way to ask that object for the current selection by index? So have code like:
In my c++ analyzer I keep a state table for which byte I am processing next, and I then setup an enum {} with symbolic names for each state. Something like:
enum DECODE_STEP
{
DE_HEADER1,
DE_HEADER2,
DE_ID,
DE_LENGTH,
DE_INSTRUCTION,
DE_DATA,
DE_CHECKSUM
};
...
switch ( DecodeIndex )
{
case DE_HEADER1:
if ( current_byte == 0xFF )
{
'''
What is a reasonable way to do similar in Python? Right now I simply am doing
if self.frame_state == 0: # find first 0xff
if ch == b'\xff':
self.frame_start_time = frame.start_time
self.frame_state = 1
elif self.frame_state == 1: # find second 0xff
if ch == b'\xff':
self.frame_second_time = frame.start_time
self.frame_state = 2
else:
self.frame_state = 0 # not a packet
...
There is probably a cleaner way?
Then questions like: With LLA, I would generate multiple result strings for the same packet.
For example for a Read operation there was code like:
else if ((packet_type == DynamixelAnalyzer::READ) && (Packet_length == 4))
{
AddResultString("R");
AddResultString("READ");
AddResultString("RD(", id_str, ")");
ss << "RD(" << id_str << ") REG: " << reg_start_str;
AddResultString(ss.str().c_str());
if ((pregister_name = GetServoRegisterName(servo_id, reg_start)))
{
ss << "(" << pregister_name << ")";
AddResultString(ss.str().c_str());
}
ss << " LEN:" << reg_count_str;
AddResultString(ss.str().c_str());
Package_Handled = true;
}
And then depending on how big the packet display area is, you would choose the largest one that would fit…
Is there something like this for the HLA?
HLA Table output, Is there a psuedo standard for HLAs? Example I am no where near done yet, but I broke out the write commands from the others so far: So I have some data like:
I have the write and dynamixel split out in the result types:
result_types = {
'simple': {
'format': '{{data.cmd}} ID:{{data.id}}'
},
'write': {
'format': '{{data.cmd}} ID:{{data.id}} REG:{{data.reg}} = {{data.data}}'
},
'dynamixel': {
'format': 'ID:{{data.id}} {{data.cmd}} {{data.data}}'
}
}
Is this a preferred way? or is it better to have most/all of one HLA all show up under the same “type” in the table?
That is all for now, for sure will probably have other questions. Again sorry if this is a repeat of some other thread.