Closed larsgk closed 7 years ago
@larsgk
I've a private branch when I started this, together with a bunch of other improvements, it's a work in progress that involves also some small change in API (so it needs for a serial2
release). I don't have it at hand right now, I'll publish it later today so you can take a look. The hard part is how to implement this feature across different OS. Do you have an idea already, in particular for Windows and OSX?
might facchinm@3cfbd2f make the windows comm more stable
I don't know, TBH I haven't had any stability problem until now, maybe this will solve some corner cases that I've not encountered until now?
@cmaglie Maybe the node-serialport project can be used for inspiration - it seems to work quite well across platforms:
https://github.com/EmergingTechnologyAdvisors/node-serialport
Code for inspiration:
https://github.com/EmergingTechnologyAdvisors/node-serialport/blob/master/src/serialport_win.cpp https://github.com/EmergingTechnologyAdvisors/node-serialport/blob/master/src/serialport_unix.cpp
Also the serial API for Chrome apps has a very nice listing of devices: https://developer.chrome.com/apps/serial
Additionally, it would be great with some event on changes so polling is not needed (not sure that's easy on all platforms)
@cmaglie Here is a gist of what seems to work for windows and linux:
https://gist.github.com/larsgk/932232c83d6d21d9040bc6694d6c7b1d
Beware: I hacked it to work - so some love should probably be applied to the code to make it production ready :)
Hi @larsgk sorry for the delay in answering here, life gets in the way sometimes :-)
Thank you for the snippets, in particular for windows, didn't know about the go-ole library! Is this code original from you? I'm asking just in case we need to sort out credit/licensing issues.
Did you look, by any chance, to this pull-request #5? is a refactoring of the API, to make it more go-lang style and, among the other things, I used that branch to build an USB-discovery API too, in particular in this commit there is my first attempt to implement USB-discovery on windows (more or less working but not finalized, I think that your code may be a better solution).
In particular in the commit above I added the following API:
type PortDetails struct {
Name string
IsUSB bool
VID string
PID string
ISerial string
}
// GetDetailedPortsList tries to retrieve port details
func GetDetailedPortsList() ([]PortDetails, error) {
return nativeGetDetailedPortsList()
}
so for each OS we can implement the private function nativeGetDetailedPortsList()
to get the port list with full-details (or return a "not-implemented" error if the function is not available for a particular OS).
To get this implemented up-to-speed I propose the following plan:
1) let me know if you agree on the API above, if yes I can add that to the v1
version of the library with an empy implementation for each os
2) merge #5
3) once merged, we can open separate pull-request to implement the nativeGetDetailedPortsList
for each OS.
Let me know what do you think.
Additionally, it would be great with some event on changes so polling is not needed (not sure that's easy on all platforms)
About this one, I'm not sure I want an event based approach, what I usually do in go-lang is spawning a new go-routine with a reader loop that just use the blocking read function (so no polling, just using the blocking read functions on a separate thread).
BTW let's focus on USB discovery on this issue, and open another one to discuss this topic.
I did the code myself but pulled inspiration from a number of code snippets from related node and golang projects. It should be cleaned up in all cases :). I am opening my go-webserial project (private -> public) after cleanup and will send u an invite now
On Oct 2, 2016 14:55, "Cristian Maglie" notifications@github.com wrote:
Hi @larsgk https://github.com/larsgk sorry for the delay in answering here, life gets in the way sometimes :-)
Thank you for the snippets, in particular for windows, didn't know about the go-ole library! Is this code original from you? I'm asking just in case we need to sort out credit/licensing issues.
Did you look, by any chance, to this pull-request https://github.com/bugst/go-serial/pull/5 #5 https://github.com/bugst/go-serial/pull/5? is a refactoring of the API, to make it more go-lang style and, among the other things, I used that branch to build an USB-discovery API too, in particular in this commit https://github.com/bugst/go-serial/commit/94406183e5d4543ffdc2f8fcf381429814694fdc there is my first attempt to implement USB-discovery on windows (more or less working but not finalized, I think that your code may be a better solution).
In particular in the commit above I added the following API:
type PortDetails struct { Name string IsUSB bool VID string PID string ISerial string } // GetDetailedPortsList tries to retrieve port detailsfunc GetDetailedPortsList() ([]PortDetails, error) { return nativeGetDetailedPortsList() }
so for each OS we can implement the private function nativeGetDetailedPortsList() to get the port list with full-details (or return a "not-implemented" error if the function is not available for a particular OS).
To get this implemented up-to-speed I propose the following plan:
1) let me know if you agree on the API above, if yes I can add that to the v1 version of the library with an empy implementation for each os 2) merge #5 https://github.com/bugst/go-serial/pull/5 3) once merged, we can open separate pull-request to implement the nativeGetDetailedPortsList for each OS.
Let me know what do you think.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bugst/go-serial/issues/6#issuecomment-250969993, or mute the thread https://github.com/notifications/unsubscribe-auth/AA97lrpOiVJqx7yOweMdssl8PMMDGfneks5qv6mugaJpZM4JwNrl .
Here we go!
For easier identification (well. any really :)) it would make sense to add VID/PID and PnP info to the listing when the serial port originates from USB (not legacy RS232).
If dev time is an issue, I'd be happy to give it a go.
BTW (offtopic) - might https://github.com/facchinm/go-serial/commit/3cfbd2fab741f7c9d238cb3bd17980110c81bd46 make the windows comm more stable?