edgexfoundry-holding / device-gps

Apache License 2.0
4 stars 7 forks source link

Move the scan logic to HandleReadCommands instead of Initialize #30

Open cloudxxx8 opened 5 years ago

cloudxxx8 commented 5 years ago

Currently, the scan logic of GPS Device Service is located in Initialize func, it caused this Device Service can only serve one GPS Device. By moving to HandleReadCommands func, it can read ProtocolProperties as the suggestion in #29. The disadvantage is that it can only scan at runtime. In the next release, this logic could move to the new AddDevice callback stated in https://github.com/edgexfoundry/device-sdk-go/issues/276 This issue is just a suggestion.

alexcourouble commented 5 years ago

We decided to implement this in the Initialize function as a go-routine to enable reading from a mock data file and to avoid the overhead associated with opening the file/device every time HandleReadCommand is invoked.

If I understand correctly, we can't access [DeviceList.Protocols.gps] from Initialize? If not, I think we should leave it hard coded on line 62 of driver/gpsdevice.go until we can use the AddDevice callback.

cloudxxx8 commented 5 years ago

Yes, Initialize can't read ProtocolProperties because ProtocolProperties is for a specific Device and Initialize is for the Device Service. AddDevice should be available by the end of this month. Device Service working group is discussing the contract of these new callback functions.

alexcourouble commented 5 years ago

Ok, I will change it once AddDevice is available.

iain-anderson commented 5 years ago

Hi @alexcourouble AddDevice etc are now in the SDK - this patch has been merged

shuxuecheng commented 5 years ago

I change the dev/ttyUSB0,but not ok.it has no vaule