Skip to content

Commit

Permalink
CAN mapping support: Remove SDO debug prints to clean up the code
Browse files Browse the repository at this point in the history
  • Loading branch information
celeron55 committed Feb 17, 2024
1 parent 02431f7 commit 5cd9bd8
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions src/openinverter_can_tool/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
from .fpfloat import fixed_to_float, fixed_from_float
from . import constants as oi

SDO_DEBUG = False

class CliSettings:
"""Simple class to store the common settings used for all commands"""

Expand Down Expand Up @@ -592,9 +590,6 @@ def cmd_can_list(

mappings = []

if SDO_DEBUG:
click.echo("Listing TX mappings")

while True:
# Request COB ID
fake_var = canopen.objectdictionary.Variable(
Expand All @@ -603,20 +598,12 @@ def cmd_can_list(
cli_settings.database.add_object(fake_var)
try:
can_id = cli_settings.node.sdo["command"].raw # SDO read
if SDO_DEBUG:
click.echo("SDO "+hex(sdo_index)+"."+str(sdo_subindex)+
": can_id="+hex(can_id))
sdo_subindex += 1
except canopen.SdoAbortedError as err:
if err.code == oi.SDO_ABORT_OBJECT_NOT_AVAILABLE:
if SDO_DEBUG:
click.echo("SDO "+hex(sdo_index)+"."+str(sdo_subindex)+
": not found")
if rx == False:
rx = True
sdo_index = oi.CAN_MAP_LIST_RX_INDEX
if SDO_DEBUG:
click.echo("Listing RX mappings")
continue
else:
break
Expand All @@ -631,14 +618,8 @@ def cmd_can_list(
cli_settings.database.add_object(fake_var)
try:
dataposlen = cli_settings.node.sdo["command"].raw # SDO read
if SDO_DEBUG:
click.echo("SDO "+hex(sdo_index)+"."+str(sdo_subindex)+
": dataposlen="+hex(dataposlen))
except canopen.SdoAbortedError as err:
if err.code == oi.SDO_ABORT_OBJECT_NOT_AVAILABLE:
if SDO_DEBUG:
click.echo("SDO "+hex(sdo_index)+"."+str(sdo_subindex)+
": not found")
sdo_index += 1
sdo_subindex = 0
break
Expand All @@ -653,14 +634,8 @@ def cmd_can_list(
cli_settings.database.add_object(fake_var)
try:
gainofs = cli_settings.node.sdo["command"].raw # SDO read
if SDO_DEBUG:
click.echo("SDO "+hex(sdo_index)+"."+str(sdo_subindex)+
": gainofs="+hex(gainofs))
except canopen.SdoAbortedError as err:
if err.code == oi.SDO_ABORT_OBJECT_NOT_AVAILABLE:
if SDO_DEBUG:
click.echo("SDO "+hex(sdo_index)+"."+str(sdo_subindex)+
": not found")
break
else:
raise err
Expand All @@ -682,9 +657,6 @@ def cmd_can_list(
mapping = CanMapping(sdo_index, sdo_subindex,
rx, can_id, param_id, param_name, position, length, gain, offset)

if SDO_DEBUG:
print("-> Decoded mapping: "+str(mapping))

mappings.append(mapping)

sdo_subindex += 1
Expand All @@ -697,9 +669,6 @@ def cmd_can_list(
if printed_can_id != mapping.can_id:
printed_can_id = mapping.can_id
click.echo(hex(printed_can_id)+":")
if SDO_DEBUG:
click.echo("* SDO "+hex(mapping.sdo_index)+"."+
str(mapping.sdo_subindex)+" ", nl=False)
click.echo(
" "
+("rx" if mapping.rx else "tx")
Expand Down Expand Up @@ -847,9 +816,6 @@ def cmd_can_remove(
sdo_index = mapping_index + (oi.CAN_MAP_LIST_RX_INDEX if txrx == "rx" else oi.CAN_MAP_LIST_TX_INDEX)
sdo_subindex = (mapping_subindex + 1) * 2

if SDO_DEBUG:
click.echo("Removing mapping at SDO "+hex(sdo_index)+"."+str(sdo_subindex))

try:
# Send COB id (CAN frame id)
fake_var = canopen.objectdictionary.Variable(
Expand Down

0 comments on commit 5cd9bd8

Please sign in to comment.