Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Retrieve desired device from DeviceManager’s hashed collection of connected devices

  • Attempt to write a subscribe request to the deviceIf the device responds with a success, add callback to device manager’s internal dictionary of callbacks
    NOTE: It does not seem possible to determine if an attribute can be subscribed to over usb until you attempt to do so, expecting that doing so will give you an error response (though error received is also unknown). Need to talk with Jabil about this.

    • As the device does not respond to subscription requests, a return of true will simply indicate that the write to the buffer of the device did not fail

Unsubscribe

...

  • Wait on the semaphore slim object before attempting to write

  • Create a DataWriter object and attach it to the SerialDevice’s output stream

  • Write the desired bytes with the DataWriter

  • Use the DataWriter’s StoreAsync method to write to the device’s output stream

  • Await a response from the device to confirm successful write (see Read above)

    • Will return false if a WASP_EWRITEFAIL is sent by the device in response

  • Release the semaphore slim

ConnectionStatusChanged

  • May Will need to periodically poll the device to determine if a change in connection has occurred

  • If a disconnect occurs without having been requested, attempt to reconnect to the device

InputStreamThread

  • On a periodic basis:

    • Create a DataReader object and attach it to the SerialDevice’s input stream

    • Set ByteOrder of DataReader to LittleEndian

    • Use the DataReader’s LoadAsync method to load bytes from the device’s input stream matching the length of the message header for Victor messages

      • Will return the number of bytes successfully read from the device

      • If no value is retrieved after a set amount of time, cancel the read attempt and delay a set amount of time before performing a new write

      • If the device is no longer valid, then a disconnect has most likely occurred. Trigger connection state change callback

    • If there are bytes read by the DataReader, use the DataReader’s ReadBytes method to read the bytes loaded from the device’s input stream

      • If the header reports the message type as a subscription

        • Read the bytes from the DataReader

        • Pass the payload to the notifications queue to trigger the appropriate callback

      • If the header reports a read response as the message type

        • Read the bytes from the DataReader

        • Pass the payload to the response data queue

...