none
SpiDevice silently happy even if non-existant RRS feed

  • Question

  • My C# code running on RP3B and Windows 10 IOT Core is working fine if e.g. a MCP3008 is correctly connected and communicated with by spi.
    But if I simply remove the adc chip, it seems like the device happily returns zeros and no exceptions are thrown.

    I will, somehow, need to handle this situation, but I am stuck on how to.

    Anyone?

    Tuesday, May 21, 2019 6:32 PM

Answers

  • Hello EuroEager,

    It seems that DeviceWatcher could not monitor the SPI device removed because of the interface in on chip(BCM2830). The workaround is that, you need to implement a custom protocol (like heartbeat) to check the communication.

    Best Regards,

    Michael


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by EuroEager Monday, June 3, 2019 7:48 PM
    Tuesday, May 28, 2019 2:40 AM

All replies

  • Hello EuroEager,

    Did you mean that SpiDevice.Read method always gets zero if you remove the chip through cutting off the connection? Could you please show the code snippet?

    Best Regards,

    Michael


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 22, 2019 1:43 AM
  • Thanks

    I am not calling the Read method, only the TransferFullDuplex method, should that be avoided?

    Code snippet may be provided, but not until a bit later today.

    Wednesday, May 22, 2019 6:33 AM
  • Hello EuroEager,

    You may try to use WriteRead instead of TransferFullDuplex method. TransferFullDuplex performs a simultaneous write and read transfer while the WriteRead  executes a write immediately followed by a read, which is not the same as calling Write method followed by Read method because the WriteRead is only one transaction while TransferFullDuplex is making two transactions.

    Best Regards,

    Michael


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 23, 2019 2:43 AM
  • Thanks again

    Please refer to documentation for the WriteRead method because I am not able to find it mentioned as a method in the Windows.Devices.Spi.SpiDevice class (or the ISpiDevice interface).

    Please also explain why you first compare WriteRead with "Write method followed by Read method" and later in the same sentence you refer to TransferFullDuplex, I just cannot follow you here.

    Thursday, May 23, 2019 7:09 AM
  • Hello EuroEager,

    Sorry for making a slip in writing. It should be Write/Read method, i means you may try to use Write and Read method instead of TransferFullDuplex to check this issue. I found out a sample here(https://github.com/dotnet/iot/tree/master/src/devices/Mcp3008). But sorry i don't have a SPI module to test this issue.

    Best Regard,

    Michael


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 23, 2019 8:55 AM
  • Thanks

    The example you refers to is identical to what I used as a start and I am running the same code as in the ReadSpi method of the Mcp3008 class (which calls TransferFullDuplex), anyway, I will try to split into a write and then a read, will report back later today.

    (if that makes sense, my knowledge about SPI is very limited on the details/"wire" level)

    Thursday, May 23, 2019 10:48 AM
  • Splitted the call into Write/Read, but no change
    Friday, May 24, 2019 3:48 PM
  • Hello EuroEager,

    In your scenario you wanted to know if the Spi Device was removed and should not read data from the device, am i right? You may try to use DeviceWatcher to monitor if the device is removed.

    Best Regards,

    Michael


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 27, 2019 3:34 AM
  • Hello Michael

    My Raspberry Pi 3B communicates with an SpiDevice of hardware type MCP3008.

    This works fine when the chip is healthy, but if the chip is broken (or like in my test case, not even physically connected), I would like to be able to generate an alarm/warning.

    Do you thing DeviceWatcher may be used for this? I tried, but cannot find a useful way of solving my "problem", please detail your hints a bit.

    Monday, May 27, 2019 8:50 PM
  • Hello EuroEager,

    It seems that DeviceWatcher could not monitor the SPI device removed because of the interface in on chip(BCM2830). The workaround is that, you need to implement a custom protocol (like heartbeat) to check the communication.

    Best Regards,

    Michael


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by EuroEager Monday, June 3, 2019 7:48 PM
    Tuesday, May 28, 2019 2:40 AM