Skip to content
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

Merged
merged 38 commits into from
Aug 29, 2022
Merged

Pingdriver #1111

merged 38 commits into from
Aug 29, 2022

Conversation

Williangalvani
Copy link
Member

@Williangalvani Williangalvani commented Aug 5, 2022

image at williangalvani/blueos-docker:pingdriver

what works:

  • hotplugging
  • bridges for ping360
  • discovery of ethernet-enabled Ping360s
  • bridges for ping1d
  • mavlink driver for ping1d
    • Toggling on/off
    • Persistence using settings system
  • new Navigator SVG from Daniel

image

Helps #264

@Williangalvani Williangalvani force-pushed the pingdriver branch 7 times, most recently from 015ce4c to 1eea259 Compare August 8, 2022 17:49
@Williangalvani Williangalvani marked this pull request as ready for review August 8, 2022 18:13
@Williangalvani Williangalvani requested review from patrickelectric and rafaellehmkuhl and removed request for patrickelectric August 8, 2022 18:13
@Williangalvani Williangalvani force-pushed the pingdriver branch 2 times, most recently from 91b0065 to 5643401 Compare August 9, 2022 01:52
Copy link
Collaborator

@ES-Alexander ES-Alexander left a 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 :-)

core/frontend/src/menus.ts Outdated Show resolved Hide resolved
core/services/ping/ping1d_driver.py Outdated Show resolved Hide resolved
core/services/ping/ping1d_mavlink.py Show resolved Hide resolved
core/services/ping/ping1d_mavlink.py Outdated Show resolved Hide resolved
core/services/ping/ping1d_mavlink.py Outdated Show resolved Hide resolved
core/services/ping/ping360_ethernet_prober.py Outdated Show resolved Hide resolved
core/services/ping/ping360_ethernet_prober.py Outdated Show resolved Hide resolved
core/services/ping/pingmanager.py Outdated Show resolved Hide resolved
core/services/ping/pingmanager.py Outdated Show resolved Hide resolved
core/services/ping/pingutils.py Outdated Show resolved Hide resolved
Copy link
Member

@patrickelectric patrickelectric left a 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:
Copy link
Member

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.

Copy link
Member Author

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:
Copy link
Member

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/ping1d_driver.py Outdated Show resolved Hide resolved
core/services/ping/ping1d_mavlink.py Outdated Show resolved Hide resolved
core/services/ping/ping1d_mavlink.py Outdated Show resolved Hide resolved
core/frontend/src/types/frontend_services.ts Show resolved Hide resolved
core/services/ping/pingmanager.py Show resolved Hide resolved
@@ -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:
Copy link
Member

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 ?

Copy link
Member Author

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...

Copy link
Member Author

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

core/services/ping/pingutils.py Show resolved Hide resolved
core/frontend/src/views/Pings.vue Outdated Show resolved Hide resolved
@Williangalvani Williangalvani force-pushed the pingdriver branch 7 times, most recently from 3e9da38 to 05f4efa Compare August 10, 2022 21:07
@Williangalvani Williangalvani requested review from ES-Alexander and patrickelectric and removed request for patrickelectric August 11, 2022 21:43
Copy link
Collaborator

@ES-Alexander ES-Alexander left a 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 :-)

core/frontend/src/components/ping/ping1d.vue Outdated Show resolved Hide resolved
core/frontend/src/menus.ts Outdated Show resolved Hide resolved
core/services/ping/ping1d_driver.py Outdated Show resolved Hide resolved
core/services/ping/ping1d_driver.py Outdated Show resolved Hide resolved
core/services/ping/ping1d_driver.py Outdated Show resolved Hide resolved
core/services/ping/pingmanager.py Outdated Show resolved Hide resolved
core/services/ping/ping360_ethernet_prober.py Outdated Show resolved Hide resolved
core/services/ping/portwatcher.py Outdated Show resolved Hide resolved
core/services/ping/portwatcher.py Outdated Show resolved Hide resolved
core/services/ping/portwatcher.py Outdated Show resolved Hide resolved
core/frontend/src/components/common/DevicePathHelper.vue Outdated Show resolved Hide resolved
core/frontend/src/components/common/DevicePathHelper.vue Outdated Show resolved Hide resolved
core/frontend/src/components/common/DevicePathHelper.vue Outdated Show resolved Hide resolved
core/frontend/src/components/common/DevicePathHelper.vue Outdated Show resolved Hide resolved
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?
Copy link
Member

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 ?

Copy link
Member

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.

Comment on lines 133 to 131
if exception.errno == errno.EAGAIN:
continue
Copy link
Member

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 ?

core/services/ping/ping1d_mavlink.py Outdated Show resolved Hide resolved
core/services/ping/ping360_ethernet_prober.py Outdated Show resolved Hide resolved
core/services/ping/ping360_ethernet_prober.py Show resolved Hide resolved
accordingly to direction
"""
port = base_port
while udp_port_is_in_use(port):
Copy link
Member

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 ?

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member

@rafaellehmkuhl rafaellehmkuhl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, really.

core/frontend/src/types/ping.ts Outdated Show resolved Hide resolved
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?
Copy link
Member

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.

Copy link
Collaborator

@ES-Alexander ES-Alexander left a 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.

Comment on lines +9 to +11
def list_ips() -> Set[str]:
"""
Returns a list of IPs found on ethernet interfaces that are currently up.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@patrickelectric patrickelectric merged commit 3a68294 into bluerobotics:master Aug 29, 2022
@Williangalvani Williangalvani deleted the pingdriver branch August 31, 2022 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants