-
-
Notifications
You must be signed in to change notification settings - Fork 520
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
Serial connection support for Windows #375
Conversation
This is mainly used to parse the URI inputs such as: - serial:///dev/ttyS0 - serial://COM3 - udp://0.0.0.0:14540
This should not change the DroneCore interface, however it makes it possible use UDP connections on other local interfaces than 0.0.0.0. Also, this gets rid of the default for serial connections because these tend to be different on every system.
core/dronecore.h
Outdated
ConnectionResult add_any_connection(const std::string &connection_url); | ||
|
||
/** | ||
* @brief Adds a UDP connection to the specified port number on 0.0.0.0 on any local interface. |
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.
Does "any local interface" mean any network? (ie I am wondering what this means as opposed to if you did not have this text)
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.
"0.0.0.0" does means "listen on any interface". So "on any local interface" here does not add information, but explicits what "0.0.0.0" means.
Here it is from Wikipedia:
In the context of servers, 0.0.0.0 can mean "all IPv4 addresses on the local machine". If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host is configured to listen on 0.0.0.0, it will be reachable at both of those IP addresses.
core/dronecore.h
Outdated
* | ||
* @param local_port_number The local UDP port to listen to (defaults to 14540, the same as mavros). | ||
* To accept only connections local connections of the machine, use 127.0.0.1, for 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.
"127.0.0.1, for any" - make that comma into a full stop and split into 2 sentences.
core/dronecore.h
Outdated
* incoming connections, use 0.0.0.0. | ||
* | ||
* @param local_bind_ip The local UDP ip to listen to. | ||
* @param local_port The local UDP port to listen to (defaults to 14540, the same as mavros). |
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.
mavros is the package name, MAVROS is the product name. I would say this is an instance of MAVROS.
@@ -50,6 +43,18 @@ class NullStream | |||
|
|||
namespace dronecore { | |||
|
|||
enum class Color { |
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 is all much nicer :-)
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.
LGTM. I don't really understand the new #if defined(WINDOWS)
part in core/serial_connection.cpp
, but anyway I don't really understand how it works for the other platforms, so I cannot really comment on that part :-).
core/dronecore.h
Outdated
ConnectionResult add_any_connection(const std::string &connection_url); | ||
|
||
/** | ||
* @brief Adds a UDP connection to the specified port number on 0.0.0.0 on any local interface. |
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.
"0.0.0.0" does means "listen on any interface". So "on any local interface" here does not add information, but explicits what "0.0.0.0" means.
Here it is from Wikipedia:
In the context of servers, 0.0.0.0 can mean "all IPv4 addresses on the local machine". If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host is configured to listen on 0.0.0.0, it will be reachable at both of those IP addresses.
Thanks @hamishwillee, I went through your comments and tried to fix them. |
* - Default Bind host IP is localhost(127.0.0.1) | ||
* | ||
* @warning Serial connections are not supported on Windows (they are supported on Linux and macOS). | ||
* Default URL : udp://0.0.0.0:14540. |
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.
@julianoes The new interface must take a connection_url
string so presumably this is no longer a default value!
Why have we chosen to not have a default anymore? Even if we choose not to have a default in the interface, why not default in the examples - passed through as argument?
If this stays the same, in addition to this update, we will need to change the usage instructions in the examples that use this method (since they also refer to default).
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.
No, the host is not a must, see:
- TCP - tcp://[Remote_host][:Remote_port]
- Serial - serial://[Dev_Node][:Baudrate]
- Serial - serial://Dev_Node[:Baudrate]
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.
Sorry, still confused. The prototype is this:
ConnectionResult add_any_connection(const std::string &connection_url);
There is no default value specified there for connection_url
(e.g. it isn't like:)
ConnectionResult add_any_connection(const std::string &connection_url=SOME_DEFAULT);
so AFAIK in C++ to call this method you must specify a value for the URL right?. So how can there be a default?
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.
Hm, you're right. There is no default. You need to specify it, and that shouild usually be done using a command line argument I suggest.
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.
@julianoes Before I do that, this is now inconsistent - the other methods (e.g. for adding UDP) do have defaults. Can you either add the default back OR remote all the other defaults?
@@ -23,11 +23,10 @@ class System; | |||
class DroneCore | |||
{ | |||
public: | |||
static constexpr auto DEFAULT_UDP_CONNECTION_URL = "udp://:14540"; | |||
static constexpr auto DEFAULT_UDP_BIND_IP = "0.0.0.0"; |
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.
@julianoes These should have doc strings (ideally)
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 see, I'll add it next time.
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.
Cheers. I mean "all of them should"
Serial connection support for Windows
This adds support for serial connections on Windows.
Todos:
add_any_connection
to work on Windows.