Author Topic: Having trouble getting C# API to work for Motion Detector Bricklet  (Read 774 times)

jonnyler

  • Newbie
  • *
  • Posts: 3
    • View Profile
So I got a master brick and a motion detector V2 bricklet hooked up, and it's connected to my PC via USB. In brickd I can see stuff happening, and in brickv it actually shows that motion is being detected. However, when I use the API -- Nothing happens. I even tried to build just the sample code, and while it seems to be getting past the connection code without any errors, no events fire.

At first I tried to see if any of the functions that would turn its LED indicators on would work, but nothing did. I then tried to see if I could get the current state using GetStatusLEDConfig(), as well as a few other methods that retrieve parameters, and each time I got the same type of exception (with different function IDs of course):
Code: [Select]
Tinkerforge.TimeoutException: 'Did not receive response in time for function ID 240'
I also made sure everything was being run as administrator.

I don't think there's any problem with the hardware, since it obviously works fine with brickv, LEDs and all, but without the API I can't really put it to use.

Does anyone have any suggestions or ideas as to what I might be doing wrong?

I'm using Visual Studio 2017 Community Edition in Windows 10.
I first tried it in Unity, and when it didn't work there I tried the sample code on its own. Even with the newest package from Nuget, I get the same results.
« Last Edit: November 26, 2018, 01:53:43 by jonnyler »

borg

  • Tinkerforge Staff
  • Administrator
  • Hero Member
  • *****
  • Posts: 3.135
    • View Profile
Re: Having trouble getting C# API to work for Motion Detector Bricklet
« Reply #1 on: November 26, 2018, 09:51:13 »
Did you use the correct UID?
Wir sind die Borg, Widerstand ist Spannung durch Stromstärke!

jonnyler

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Having trouble getting C# API to work for Motion Detector Bricklet
« Reply #2 on: November 26, 2018, 10:53:35 »
Ah... Of course. I knew I missed something, and for some reason I kept skipping right over that exact piece of the puzzle each time.

Thanks, and sorry for bothering you with something so trivial!  :-X

jonnyler

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Having trouble getting C# API to work for Motion Detector Bricklet
« Reply #3 on: November 26, 2018, 20:35:32 »
Actually, since we're on the subject, shouldn't I have gotten any errors that were more indicative of what I was missing?

That is, should you still be allowed to call set functions on a bad UID?

remotecontrol

  • Hero Member
  • *****
  • Posts: 590
    • View Profile
Re: Having trouble getting C# API to work for Motion Detector Bricklet
« Reply #4 on: November 26, 2018, 20:56:49 »
The client API does not 'track' bricklet UIDs, the master brick has this information. The timeout is an indicator that the master did not react in time to the request and this can indicate a wrong UID.

Nevertheless the API allows to work completely without UIDs if you use the enumerate feature and device type detection, so happy coding  ;)