This repository has been archived by the owner on May 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 779
[Core] Introduced discovery for USB devices with serial port #5315
Merged
sjsf
merged 14 commits into
eclipse-archived:master
from
hsudbrock:5153-discovery-for-usb-devices-with-serial-driver
Apr 5, 2018
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2568d8c
[5153] Discovery for USB devices with serial port
hsudbrock 5ce8b84
[5153] Address @amitjoy's review comment on synchronization of settin…
hsudbrock 6530263
[5153] Addresses @amitjoy's review comment regarding setting the
hsudbrock 663eeeb
[5153] Addresses @amitjoy's review comment regarding a more specific
hsudbrock 8c50f72
[5153] Addresses @triller-telekom's review comments (except those with
hsudbrock 2c3ff4c
[5153] Address review comments regarding the usbSerialDiscovery depen…
hsudbrock c5d1d9a
[5153] Address @triller-telekom's review comment regarding the use of
hsudbrock 2c22d2f
[5153] Addresses @triller-telekom's comment regarding NonNullByDefault
hsudbrock 6f6f739
[5153] Fix minor issues detected by the static code analysis
hsudbrock af5dd60
[5153] Fix failing test and make UsbSerialDiscoveryService config
hsudbrock 177d8b9
[5153] Addresses @kaikreuzer's review comment to use linuxsysfs inste…
hsudbrock 6115e2e
[5153] Addresses discussion with @triller-telekom regarding adding
hsudbrock 9c422d3
[5153] Addresses the review comments by @sjka
hsudbrock e381290
[5153] Addresses the inclusion of USB interface information into the
hsudbrock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,8 @@ public class UsbSerialDiscoveryService extends AbstractDiscoveryService implemen | |
|
||
private final Set<UsbSerialDiscoveryParticipant> discoveryParticipants = new CopyOnWriteArraySet<>(); | ||
|
||
private final Set<UsbSerialDeviceInformation> previouslyDiscovered = new CopyOnWriteArraySet<>(); | ||
|
||
@NonNullByDefault({}) | ||
private UsbSerialDiscovery usbSerialDiscovery; | ||
|
||
|
@@ -86,6 +88,12 @@ protected void activate(@Nullable Map<String, @Nullable Object> configProperties | |
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) | ||
protected void addUsbSerialDiscoveryParticipant(UsbSerialDiscoveryParticipant participant) { | ||
this.discoveryParticipants.add(participant); | ||
for (UsbSerialDeviceInformation usbSerialDeviceInformation : previouslyDiscovered) { | ||
DiscoveryResult result = participant.createResult(usbSerialDeviceInformation); | ||
if (result != null) { | ||
thingDiscovered(result); | ||
} | ||
} | ||
} | ||
|
||
protected void removeUsbSerialDiscoveryParticipant(UsbSerialDiscoveryParticipant participant) { | ||
|
@@ -101,6 +109,7 @@ protected synchronized void unsetUsbSerialDiscovery(UsbSerialDiscovery usbSerial | |
usbSerialDiscovery.stopBackgroundScanning(); | ||
usbSerialDiscovery.unregisterDiscoveryListener(this); | ||
this.usbSerialDiscovery = null; | ||
this.previouslyDiscovered.clear(); | ||
} | ||
|
||
@Modified | ||
|
@@ -146,6 +155,7 @@ protected void stopBackgroundDiscovery() { | |
@Override | ||
public void usbSerialDeviceDiscovered(UsbSerialDeviceInformation usbSerialDeviceInformation) { | ||
logger.debug("Discovered new usb-serial device: {}", usbSerialDeviceInformation); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. USB-serial There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will change. |
||
previouslyDiscovered.add(usbSerialDeviceInformation); | ||
for (UsbSerialDiscoveryParticipant participant : discoveryParticipants) { | ||
DiscoveryResult result = participant.createResult(usbSerialDeviceInformation); | ||
if (result != null) { | ||
|
@@ -157,6 +167,7 @@ public void usbSerialDeviceDiscovered(UsbSerialDeviceInformation usbSerialDevice | |
@Override | ||
public void usbSerialDeviceRemoved(UsbSerialDeviceInformation usbSerialDeviceInformation) { | ||
logger.debug("Discovered removed usb-serial device: {}", usbSerialDeviceInformation); | ||
previouslyDiscovered.remove(usbSerialDeviceInformation); | ||
for (UsbSerialDiscoveryParticipant participant : discoveryParticipants) { | ||
ThingUID thingUID = participant.getThingUID(usbSerialDeviceInformation); | ||
if (thingUID != null) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are you sure that you want to clear the Set if you remove one participant? I think you have to leave the Set untouched if you remove a participant and only remove items from it in
usbSerialDeviceRemoved
, right?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.
@triller-telekom This method is called when unsetting the
usbSerialDiscovery
, not when removing adiscoveryParticipant
.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.
Github fooled me on this one... It folded away all lines between
protected void removeUsbSerialDiscoveryParticipant(UsbSerialDiscoveryParticipant participant) {
andusbSerialDiscovery.stopBackgroundScanning();
so I did not see that your added code ended up inunsetUsbSerialDiscovery
. To me it looked as if you added it toremoveUsbSerialDiscoveryParticipant
.So all is good now :)