Getting exception working w/ Cerbot ReflectiveSensors on 4.3 R2

Trying to update some of the old Cerbot code that worked for me on the last SDK, to work on the 4.3 R2 release.

@ John - GHI pointed me to right place to update any references of CerbotController to Mainboard, and that has worked like a charm, but now I am having another issue.

I could not figure out how to access the ReflectiveSensors using Mainboard, so I tried the following code, which resolves in VS12 and builds fine, but causes an exception when it is run in debugger:


bool leftOverEdge = Mainboard.GetReflectiveReading(GHIElectronics.Gadgeteer.FEZCerbot.ReflectiveSensors.Left) < SENSOR_THRESHOLD;
bool rightOverEdge = Mainboard.GetReflectiveReading(GHIElectronics.Gadgeteer.FEZCerbot.ReflectiveSensors.Right) < SENSOR_THRESHOLD;

I get the following exception errors:

A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll

Thanks!

It looks like I forgot to add a call to SetAnalogInputFactors when creating the internal socket for the reflective sensors. You can download the mainboard source on https://bitbucket.org/ghi_elect/gadgeteer/ and add the following code after line 185 in FEZCerbot_43.cs.


GT.Socket.SocketInterfaces.SetAnalogInputFactors(socket, 3.3, 0, 12);

1 Like

@ John - thanks for the reply. Sorry to be such a newb, but what do I do with said file, once I update it? I assume it gets compiled and/or copied somewhere into one of the GHI NETMF dirs? I am pretty new to C# and NETMF in general. Sorry.

1 Like

@ Beedlebub - Sorry, I forgot to mention you should add the Cerbot mainboard project to your solution and add a reference to it instead of the built in DLL. https://www.ghielectronics.com/docs/122/gadgeteer-driver-modification should be helpful.

1 Like

Thanks for the help guys, but I’m not getting something. One last shot maybe…

  • Copied down repo (ghi_elect-gadgeteer-9a190d54c3eb) as zip to local machine
  • Copied out “Mainboards\GHIElectronicsLegacy\FEZCerbot” to my local VS12 projects dir
  • Used “add” in VS12 Solution Explorer to add “FEZCerbot_43” project to my existing solution
  • Added “GT.Socket.SocketInterfaces.SetAnalogInputFactors(socket, 3.3, 0, 12);” line at 186 in “FEZCerbot_43.cs”
  • Added reference inside my previous project to “FEZCerbot_43”
  • Removed reference to “GHIElectronic.Gageteer.FEZCerbot”
  • Build

I get the following errors…directions provided in that link are quite sparse, (and the images are low res) for a newb :wink:

Am I adding this wrong, or do I need to change references in my code in some way now?

Error 1 Source file ‘…\Modules\GHIElectronicsLegacy\Shared\AssemblyInfoGlobal43.cs’ could not be found C:\Users\Brand\Documents\Visual Studio 2012\Projects\FEZCerbot\FEZCerbot_43\CSC FEZCerbot_43

Error 2 GenerateResource.ReferencedAssemblyNotFound - C:\Users\Brand\Documents\Visual Studio 2012\Projects\FEZCerbot\FEZCerbot_43\bin\Debug\GHIElectronics.Gadgeteer.FEZCerbot.dll: Could not load file or assembly ‘GHIElectronics.Gadgeteer.FEZCerbot.dll’ or one of its dependencies. The system cannot find the file specified.
Parameter name: C:\Users\Brand\Documents\Visual Studio 2012\Projects\FEZCerbot\FEZCerbot_43\bin\Debug\GHIElectronics.Gadgeteer.FEZCerbot.dll Cerbot_edgeDetection

Sorry, really one last plea for help…

I started all over again, and copied the FULL repo to my VS2012 Projects folder this time,and then re-added as in prev post.

Actually builds now without errors, but when trying to deploy, I get the following errors. Hoping I am just missing one simple thing now…

Create TS.

Loading start at 806ebf4, end 8094b80

Assembly: mscorlib (4.3.1.0) Assembly: Microsoft.SPOT.Native (4.3.1.0) Assembly: Microsoft.SPOT.Hardware (4.3.1.0)
Assembly: Microsoft.SPOT.Graphics (4.3.1.0) Assembly: Microsoft.SPOT.TinyCore (4.3.1.0)
Assembly: Microsoft.SPOT.IO (4.3.1.0) Assembly: System.IO (4.3.1.0) Assembly: Microsoft.SPOT.Hardware.Usb (4.3.1.0)
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.3.1.0) Assembly: Microsoft.SPOT.Hardware.PWM (4.3.1.0)
Loading Deployment Assemblies.

Attaching deployed file.

Assembly: Gadgeteer (2.43.1.0) Attaching deployed file.

Assembly: Gadgeteer.SPI (2.43.1.0) Attaching deployed file.

Assembly: Microsoft.SPOT.Net (4.3.1.0) Attaching deployed file.

Assembly: GHIElectronics.Gadgeteer.FEZCerbot (4.3.3.0) Attaching deployed file.

Assembly: Cerbot_edgeDetection (1.0.0.0) Resolving.

Link failure: some assembly references cannot be resolved!!

Assembly: GHIElectronics.Gadgeteer.FEZCerbot (4.3.3.0) needs assembly ‘GHI.Hardware’ (4.3.3.0)

Assembly: GHIElectronics.Gadgeteer.FEZCerbot (4.3.3.0) needs assembly ‘GHI.Pins’ (4.3.3.0)

Assembly: Cerbot_edgeDetection (1.0.0.0) needs assembly ‘GHIElectronics.Gadgeteer.FEZCerbot’ (4.3.3.0)

Error: a3000000

Waiting for debug commands…

The program ‘[1] Micro Framework application: Managed’ has exited with code 0 (0x0).

@ Beedlebub - The a3000000 usually means your firmware is out of date. Try updating it and make sure the assemblies referenced in all of your projects correctly point to the ones in our SDK, except the Cerbot one in your project.

Thanks guys. I can confirm these two things:

  • Firmware is def up to date, according to GHIConfig. Also, any other project I compile runs fine on this Mainboard with all the new SDKs. Its just when I reference the ReflectiveSensors that I run into these issues.

  • My assemblies are all fine and working, across other boards and other programs. I only get this new error after I added the new Cerbot_43 reference. I def ONLY removed the reference to GHIElectronic.Gageteer.FEZCerbot, which would have been in conflict with new reference that was added.

Hope that helps some. Since this is a legacy product, I don’t expect too much support, but would thank you greatly, if I didn’t have to roll back everything - GHI SDK, NETMF SDK, firmware, etc. to use this really fun board again.

Thanks!

@ andre.m - This is where it gets cloudy. I added the source to my solution, as I was told to by John earlier in the thread. Then in the instructions found in the URL posted in his reply, it said to add the reference in Solution Explorer, and remove the old, non-working reference, which I also did.

Hopefully that made sense. If not, the exact steps I performed are listed out in one my earlier replies. Maybe something is listed there that I am doing wrong? Thanks for all the help!

@ andre.m - Progress!!! Program runs now! Thanks so much for you help and patience!

  • Removed references to GHI.pins and GHI.hardware from proj b (FEZCerbot_43) and added them back to proj b…same exact errors

  • I then removed and added same refs from proj a (my code - Cerbot_edgeDetection) and everything then worked as expected!

  • Still see some errors/warnings though, which I am pasting in below. Is it safe to assume I need to do this merge, delete/add ref for Cerbot, pins and hardware for any code I write moving forward, and that the warnings below don’t mean anything really?

Found debugger!

Create TS.

Loading start at 806ebf4, end 8094b80

Assembly: mscorlib (4.3.1.0) Assembly: Microsoft.SPOT.Native (4.3.1.0) Assembly: Microsoft.SPOT.Hardware (4.3.1.0)
Assembly: Microsoft.SPOT.Graphics (4.3.1.0) Assembly: Microsoft.SPOT.TinyCore (4.3.1.0)
Assembly: Microsoft.SPOT.IO (4.3.1.0) Assembly: System.IO (4.3.1.0) Assembly: Microsoft.SPOT.Hardware.Usb (4.3.1.0)
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.3.1.0) Assembly: Microsoft.SPOT.Hardware.PWM (4.3.1.0)
Loading Deployment Assemblies.

Attaching deployed file.

Assembly: Gadgeteer (2.43.1.0) Attaching deployed file.

Assembly: GHI.Hardware (4.3.3.0) Attaching deployed file.

Assembly: Gadgeteer.SPI (2.43.1.0) Attaching deployed file.

Assembly: GHI.Pins (4.3.3.0) Attaching deployed file.

Assembly: Microsoft.SPOT.Net (4.3.1.0) Attaching deployed file.

Assembly: GHIElectronics.Gadgeteer.FEZCerbot (4.3.3.0) Attaching deployed file.

Assembly: Cerbot_edgeDetection (1.0.0.0) Resolving.

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\mscorlib.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Native.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Graphics.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.TinyCore.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.IO.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.IO.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.Usb.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Net.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Gadgeteer\Core\Assemblies.NET Micro Framework 4.3\le\Gadgeteer.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.3 SDK\Libraries\le\GHI.Hardware.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Gadgeteer\Core\Assemblies.NET Micro Framework 4.3\le\Gadgeteer.SPI.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.3 SDK\Libraries\le\GHI.Pins.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\Brand\Documents\Visual Studio 2012\Projects\ghi_elect-gadgeteer-9a190d54c3eb\ghi_elect-gadgeteer-9a190d54c3eb\Mainboards\GHIElectronicsLegacy\FEZCerbot\FEZCerbot_43\bin\Debug\le\GHIElectronics.Gadgeteer.FEZCerbot.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\Brand\Documents\Visual Studio 2012\Projects\Cerbot_edgeDetection\Cerbot_edgeDetection\bin\Debug\le\Cerbot_edgeDetection.exe’, Symbols loaded.
The thread ‘’ (0x2) has exited with code 0 (0x0).

Warning: socket 10 is not compliant with Gadgeteer : Cpu pin 5 must be specified for socket of type S
Warning: socket 10 is not compliant with Gadgeteer : Cpu pin 5 must be specified for socket of type Y
Warning: socket 10 is not compliant with Gadgeteer : Cpu pin 5 must be specified for socket of type X
Warning: socket 11 is not compliant with Gadgeteer : Cpu pin 5 must be specified for socket of type X
Warning: socket 11 is not compliant with Gadgeteer : Cpu pin 6 must be specified for socket of type P
Warning: socket 12 is not compliant with Gadgeteer : Cpu pin 5 must be specified for socket of type A
Warning: socket 12 is not compliant with Gadgeteer : Cpu pin 6 must be specified for socket of type A
Warning: socket 12 is not compliant with Gadgeteer : Socket of type A must support analog input functionality on pins 3, 4 and 5
Warning: socket 12 is not compliant with Gadgeteer : Cpu pin 6 must be specified for socket of type P
Warning: socket 12 is not compliant with Gadgeteer : Cpu pin 9 must be specified for socket of type P
Warning: socket 12 is not compliant with Gadgeteer : Socket of type P must support PWM functionality

Using mainboard GHI Electronics FEZ Cerbot version 1.3
Program Started
The thread ‘’ (0x3) has exited with code 0 (0x0).
The program ‘[4] Micro Framework application: Managed’ has exited with code 0 (0x0).

@ John - The MF 4.2 and MF 4.3 cerbot source seem to be no longer available on https://bitbucket.org/ghi_elect/gadgeteer/ .

Under “Gadgeteer/Mainboards/GHIElectronics” I can only find the FEZCerberus source but not the source for FEZCerbot.

Probably the branch for discontinued Mainboards is hidden for newbies.

We did remove the mainboards from the legacy SDK since they are required to be rebuilt every time we release a new version of the libraries. You can still find them in the git history if truly needed. Given that the Cerbot was the only mainboard with specific functionality not found in existing non-legacy mainboards, we created a codeshare for its onboard functionality: https://www.ghielectronics.com/community/codeshare/entry/926

My suggestion is to use code share with pure netmf, no gadgeteer. If using gadgeteer us required then using 4.2 maybe easier in the old sdk maybe easier.

If your are comfortable with the source in the repositories the you can use 4.3 no problem.

10 days ago John posted a solution in this thread for Cerbot & gadgeteer under 4.3 but the source for FEZCerbot_43.cs has been moved away.

So please make a codeshare or whatever you like for FEZCerbot_43.cs and fill it into this thread so that customers will be able to add the missing line to the driver, or even better download a corrected one …

Thanks,

– Klaus.