-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add debug broadcast enable/disable option and debug broadcast port option to config file #309
base: main
Are you sure you want to change the base?
Conversation
…tion to config file
|
I have tested pretty thoroughly on a YRC1000 on humble and I did not run into any issues. |
CI failures of the |
…guide, and remove extra whitespace in yaml file to pass linter.
9e7033f
to
fe4c0a2
Compare
@gavanderhoorn I went through and fixed the other failing checks, thanks for pointing that out. I wasn't sure which checks I should ignore. |
doc/troubleshooting.md
Outdated
|
||
*Solution:* | ||
The `userlan_debug_broadcast_port` key in the `motoros2_config.yaml` configuration file is set to an invalid value. | ||
Debug broadcasting will be disabled for this session. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug broadcasting will be disabled for this session
I don't like this behavior. I definitely think broadcasting should be enabled if there's an error in the configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change that. So userlan_monitoring_enabled
should be set to disabled if there is an error in the config, but broadcasting should still be enabled? I only ask because they're in the same case for the config switch case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have an opinion on the behavior of userlan_monitoring_enabled
in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserLan monitoring is extra functionality: it makes detecting disconnections faster, but isn't absolutely necessary (other places will also detect disconnects, they'll just take longer).
There's no harm in disabling it if the configuration is incorrect. And, we really can't do anything if configuration is incorrect: monitoring only a single port (when two are present) would be incorrect (which one to monitor in that case?) and monitoring all of them would also be incorrect -- it would likely result in MotoROS2 detecting disconnects 'all the time'. So disabling is really the only thing we can do.
But debug broadcasts should indeed not be disabled in cases of incorrect configuration. Especially since we often use debug logs to diagnose misconfiguration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the behavior and this documentation so that it broadcasts to all ports if the specific port isn't active.
…t, rename values to prevent potential clashes, get rid of duplicate checks and improve efficiency.
@@ -690,7 +696,7 @@ void Ros_ConfigFile_ValidateNonCriticalSettings() | |||
if (g_nodeConfigSettings.userlan_monitor_port != CFG_ROS_USER_LAN1) | |||
#endif | |||
{ | |||
mpSetAlarm(ALARM_CONFIGURATION_FAIL, "Invalid UserLan port in cfg", | |||
mpSetAlarm(ALARM_CONFIGURATION_FAIL, "Bad UserLan monitor port in cfg", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you have a particular reason changing the phrasing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are now 2 different UserLan ports that the user can specify (monitor and debug broadcast), so I added the word "monitor" to clarify which one this condition checked. But then that put it above 32 characters (the alarm message limit), so I chose to shorten "Invalid" to "Bad" to fit in the character limit. I think that "invalid" is a better word for that, but it's more important to be specific about which config setting needs to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So should we instead separate parsing and error reporting for monitoring and debug log port?
Would lead to some mild code duplication, but would also make parsing clearer and avoids this situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe that this specific message is affected by combined parsing/error reporting for the two port config options. My preference would be to keep the parsing as combined, but I would be fine with changing it.
CFG_ROS_USER_LAN_DISABLED = -2, //sentinel | ||
CFG_ROS_USER_LAN_MALFORMED = -3, //sentinel | ||
CFG_ROS_USER_LAN_ALL = -2, //sentinel | ||
CFG_ROS_USER_LAN_AUTO = -1, //sentinel | ||
CFG_ROS_USER_LAN1 = ROS_USER_LAN1, | ||
CFG_ROS_USER_LAN2 = ROS_USER_LAN2, | ||
} Ros_UserLan_Port_Setting; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand why you opted to reuse the Ros_UserLan_Port_Setting
type, but it does make the parsing code a little harder to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I tried doing it both ways, and this had much less duplicated code and was overall cleaner in my opinion. I don't especially like it either though.
config/motoros2_config.yaml
Outdated
# OPTIONS: USER_LAN1, USER_LAN2 | ||
# DEFAULT: (all available network ports) | ||
#userlan_debug_broadcast_port: USER_LAN1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what would be the value (ie: string) for 'all available network ports'? Because the documentation states that's the default, but I can't set this to 'all available network ports'
I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there is not a dedicated string for 'all available ports'. I was planning on having that, but part of the weirdness with it having the same type as userlan_monitor_port
(Ros_UserLan_Port_Setting
) is that even if they have different options with different behavior (e.g. userlan_monitor_port
has 'auto detection' and userlan_debug_broadcast_port
has 'all available ports'), they are parsed the same. So I had the behavior match that of userlan_monitor_port
, which doesn't have a specific string for 'auto detection'. That being said, unlike userlan_monitor_port
, if the user types in an invalid string, it will default to 'all available ports' rather than 'disabled'
…in config file. Update style, improve wording in documentation, and change names of variables.
I'll test this on my YRC1 and FS1 next week. |
Even with single-statement bodies.
I've not tested this extensively yet (I will try to do that now), but as a high-level initial comment I might suggest adding some more comments. From a quick read it's not immediately clear why only |
Ros_Debug_Init(); | ||
} | ||
|
||
if (!g_nodeConfigSettings.debug_broadcast_enabled && !g_nodeConfigSettings.log_to_stdout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might also be a nice place to explain why this will allow control flow to continue here if g_nodeConfigSettings.log_to_stdout == TRUE
?
(because we can reuse all the machinery after this to format the message and as ros_debugPorts.enabledPortCount
is most likely 0
, nothing will be sent out over any of the LAN ports, but it will be printed to the controller's console. IIUC).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimmy-mcelwain: I'm wondering whether this works as intended (specifically this line).
Could it be this prevents logs from getting broadcast until at least the config file has been parsed? Both debug_broadcast_enabled
and log_to_stdout
will be FALSE
in that case I believe.
Looking at the debug log output of my YRC1, it seems to be missing at least these printouts (maybe more):
Lines 60 to 64 in c61fb86
Ros_Debug_BroadcastMsg("---"); | |
Ros_Debug_BroadcastMsg(APPLICATION_NAME " %s - boot", APPLICATION_VERSION); | |
Ros_Debug_BroadcastMsg("M+ libmicroros version: '%s'", MOTOPLUS_LIBMICROROS_VERSION_STR); | |
Ros_Debug_BroadcastMsg("PlatformLib version: %u.%u.%u", MOTOROS_PLATFORM_LIB_MAJOR, | |
MOTOROS_PLATFORM_LIB_MINOR, MOTOROS_PLATFORM_LIB_PATCH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you're right. Maybe if we call Ros_ConfigFile_SetAllDefaultValues()
to set debug_broadcast_enabled
to TRUE
in main
before any calls to Ros_Debug_BroadcastMsg()
, then we would be able to broadcast those messages. I would need to think it through more though, that might require more changes.
I added 2 extra settings to the
motoros2_config.yaml
file,userlan_debug_broadcast_enabled
anduserlan_debug_broadcast_port
. By default, it broadcasts to all enabled ports, but the user can choose a specific port if they only want it to broadcast to one port, or the user can disable it.