-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Create and populate UART message to log serial port information #17360
Create and populate UART message to log serial port information #17360
Conversation
libraries/AP_HAL/UARTDriver.cpp
Outdated
|
||
void AP_HAL::UARTDriver::update_logging_all() | ||
{ | ||
hal.uartA->update_logging(); |
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 we might now have an array for this.
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.
It would be a lot nicer if we did...
Found in AP_SerialManager for the init:
// initialise serial ports
for (uint8_t i=1; i<SERIALMANAGER_NUM_PORTS; i++) {
auto *uart = hal.serial(i);
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.
It would be a lot nicer if we did...
Found in AP_SerialManager for the init:
// initialise serial ports for (uint8_t i=1; i<SERIALMANAGER_NUM_PORTS; i++) { auto *uart = hal.serial(i);
Thanks.
Interestingly different from other places using num_serial
in place of SERIALMANAGER_NUM_PORTS
typedef ObjectArray<float> FloatArray; No newline at end of file | ||
typedef ObjectArray<float> FloatArray; |
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.
Remove this
21bfd73
to
b9bf32b
Compare
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.
not done for linux ?
libraries/AP_HAL/UARTDriver.cpp
Outdated
_stats.tx_buffer_min = -1; // using integer wrap | ||
} | ||
|
||
const struct log_UART pkt = { |
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.
Can we log throughput in baud somehow?
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.
Yes, probably just the sum of bytes transmitted.
nice idea! just needs a few less 'stuff' commits :-) |
libraries/AP_HAL/UARTDriver.cpp
Outdated
instance : (uint8_t)_instance, | ||
rxq_min : stats_copy.rx_buffer_min, | ||
rxq_max : stats_copy.rx_buffer_max, | ||
rxq_avg : (stats_copy.rx_buffer_bytes_available_count == 0) ? (uint16_t)0 : uint16_t(stats_copy.rx_buffer_bytes_available_sum/stats_copy.rx_buffer_bytes_available_count), |
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.
It's a style thing, but casting the whole return from the touple to uint16_t is a bit less verbose
libraries/AP_HAL/UARTDriver.cpp
Outdated
// reset statistics | ||
memset(&_stats, 0, sizeof(_stats)); | ||
_stats.rx_buffer_min = -1; // using integer wrap | ||
_stats.tx_buffer_min = -1; // using integer wrap |
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.
Don't you have to reset the max's to 0 as well?
|
||
// logging-related variables | ||
struct Stats { | ||
HAL_Semaphore sem; |
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.
Why is the semaphore within the struct? This means we are copying the semaphore for as part of copying the struct when we are logging (IE it's just wasted time on copying it)
@@ -660,6 +661,7 @@ bool UARTDriver::discard_input() | |||
} | |||
|
|||
_readbuf.clear(); | |||
update_readbuf_stats(); |
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.
Don't you need to have the semaphore here?
} | ||
void UARTDriver::update_readbuf_stats() | ||
{ | ||
const uint32_t available = _readbuf.available(); |
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.
It feels like it's easier to add the semaphore holding in here, rather then making all the callers be responsible for having it.
{ | ||
WITH_SEMAPHORE(_stats.sem); | ||
_stats.rx_bytes += count; | ||
update_readbuf_stats(); |
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.
Why not have update_readbuf_stats
take the number of new read bytes as an argument and adding it internally? It seems like you always basically have a new number to add (or 0 I guess for the clear case)
@@ -706,6 +716,14 @@ int16_t UARTDriver::read() | |||
update_rts_line(); | |||
} | |||
|
|||
#if HAL_LOG_UART_STATS | |||
{ | |||
WITH_SEMAPHORE(_stats.sem); |
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'd be curious how much time grabbing this semaphore for all the drivers that read byte by byte add's up to? I'm just thinking about the companion computer/MAVLink links at near 1 megabaud. It's probably fine, it just seems like it could be a bit of a factor.
b9bf32b
to
49f9b9f
Compare
49f9b9f
to
440318a
Compare
440318a
to
f94c335
Compare
No description provided.