ANT_DeviceInfo.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except
  4. in compliance with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2016
  6. All rights reserved.
  7. */
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. namespace ANT_Managed_Library
  13. {
  14. /// <summary>
  15. /// Container for all the USB Device information, returned from an ANTDevice
  16. /// </summary>
  17. public class ANT_DeviceInfo
  18. {
  19. /// <summary>
  20. /// USB Device Product Description
  21. /// </summary>
  22. public byte[] productDescription;
  23. /// <summary>
  24. /// USB Device Serial String
  25. /// </summary>
  26. public byte[] serialString;
  27. internal ANT_DeviceInfo(byte[] productDescription, byte[] serialString)
  28. {
  29. this.productDescription = productDescription;
  30. this.serialString = serialString;
  31. }
  32. /// <summary>
  33. /// Returns a formatted, readable string for the product description
  34. /// </summary>
  35. public String printProductDescription()
  36. {
  37. return printBytes(productDescription);
  38. }
  39. /// <summary>
  40. /// Returns a formatted, readable string for the serial string
  41. /// </summary>
  42. public String printSerialString()
  43. {
  44. return printBytes(serialString);
  45. }
  46. private String printBytes(byte[] rawBytes)
  47. {
  48. // Decode as null terminated ASCII string
  49. string formattedString = System.Text.Encoding.ASCII.GetString(rawBytes);
  50. return (formattedString.Remove(formattedString.IndexOf('\0')));
  51. }
  52. };
  53. }