-
Notifications
You must be signed in to change notification settings - Fork 84
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
Pingdriver #1111
Pingdriver #1111
Conversation
015ce4c
to
1eea259
Compare
91b0065
to
5643401
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.
New UI is great!
Love the images that show where things are plugged in, and it'll be great to have Ping1D MAVLink messages again (one step closer to full Companion replacement). Also really cool that it detects Ping360s over ethernet. From a support standpoint this update should be super helpful - thanks! :-)
No bugs found, just some minor improvements and consideration points :-)
8b171d8
to
39ce58d
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.
An initial review, will catch up later
@@ -40,6 +40,14 @@ def get_sensors() -> Any: | |||
return [PingDeviceDescriptorModel.from_descriptor(device) for device in ping_manager.devices()] | |||
|
|||
|
|||
@app.post("/sensors", status_code=status.HTTP_200_OK, summary="Set sensor settings.") | |||
@version(1, 0) | |||
def set_sensor(sensor_settings: dict[str, Any]) -> Any: |
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't we enforce a format for the post message ? Like we have in the others services.
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.
the goal here is to have a somewhat abstract interface we can use for all sensors eventually, the goal is to have simple key:values for now, but allowing at least the basic types
@app.post("/sensors", status_code=status.HTTP_200_OK, summary="Set sensor settings.") | ||
@version(1, 0) | ||
def set_sensor(sensor_settings: dict[str, Any]) -> Any: | ||
if "port" not in sensor_settings: |
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 should be not necessary if we enforce the post type.
core/services/ping/pingmanager.py
Outdated
@@ -27,15 +27,27 @@ async def register_ethernet_ping360(self, ping: PingDeviceDescriptor) -> None: | |||
if ping not in self.drivers: | |||
self.drivers[ping] = Ping360Driver(ping, -1) | |||
|
|||
def find_next_port(self, base_port: int, direction: int) -> int: |
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 using port 0
to bind and get the port that the OS found for us ?
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 prefer following some kind of order for now...
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.
also, we're starting at the ports checked by pingviewer for now. we still dont´t have the discovery protocol implemented for alternative ports
3e9da38
to
05f4efa
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.
A few more clarity / consistency suggestions, but nothing major :-)
board_type() : BoardType { | ||
/* Detects board type between navigator and Rpi4 */ | ||
// TODO: make sure this works with pi3 as well | ||
const serial_port_path = this.serial_port_path as string // why is it needed? |
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.
@rafaellehmkuhl do you know what the cast is necessary ?
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.
Apparently because in line 66 it can return undefined
if port is not defined.
core/services/ping/ping1d_mavlink.py
Outdated
if exception.errno == errno.EAGAIN: | ||
continue |
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'm inclined to agree with @ES-Alexander here, why EAGAIN
is special over others that needs his special continue
?
accordingly to direction | ||
""" | ||
port = base_port | ||
while udp_port_is_in_use(port): |
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.
We should limit the range that the port can be.
At least between 9090 and 9099, otherwise we could start having numbers totally outside the range if 3rd party programs are using it, without us having control to find the sensors with ping-viewer.
We should also start thinking about how ping-viewer is going to discover this devices, how that works currently ?
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 see the point in limiting it. Discovery needs to be improved in PingViewer.
As is it will work fine for one Ping1D and one Ping360.
We could either use the Ping360 discovery protocol, or ask Beacon to broadcast the devices using mDNS
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 limiting the range will result in a silent loop block where there is no condition to exit besides the OS saying that a port is available, if no port is available, this loop will never exit. But if you don't have strong feelings that such thing will never happen I'm ok with it.
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.
Nice work, really.
board_type() : BoardType { | ||
/* Detects board type between navigator and Rpi4 */ | ||
// TODO: make sure this works with pi3 as well | ||
const serial_port_path = this.serial_port_path as string // why is it needed? |
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.
Apparently because in line 66 it can return undefined
if port is not defined.
…deal with pydantic 1.10.0a2
5d7ef9c
to
1ba1a23
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.
I'm short on brainpower at the moment so this wasn't a super in depth review, but great to see the logging has been added, and in general still looking good! :-)
One minor suggestion on naming correctness.
def list_ips() -> Set[str]: | ||
""" | ||
Returns a list of IPs found on ethernet interfaces that are currently up. |
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.
def list_ips() -> Set[str]: | |
""" | |
Returns a list of IPs found on ethernet interfaces that are currently up. | |
def get_available_ips() -> Set[str]: | |
""" | |
Returns a set of IPs found on ethernet interfaces that are currently up. |
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.
image at williangalvani/blueos-docker:pingdriver
what works:
Helps #264