Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

'AnalogInput' is an ambiguous reference after 4.2 RC1


  • Please log in to reply
10 replies to this topic

#1 maara

maara

    Member

  • Members
  • PipPip
  • 10 posts

Posted 04 September 2011 - 06:49 PM

Hi,

I recently installed MF 4.2 RC1 and correcponding netduino sdk but now I am facing following issue while using analog inputs (even while running tutiorials - I am kind new to c#...)

var port1 = new AnalogInput(Pins.GPIO_PIN_A0);



Error 1 'AnalogInput' is an ambiguous reference between 'Microsoft.SPOT.Hardware.AnalogInput' and 'SecretLabs.NETMF.Hardware.AnalogInput'
Error 2 The best overloaded method match for 'Microsoft.SPOT.Hardware.AnalogInput.AnalogInput(Microsoft.SPOT.Hardware.Cpu.AnalogChannel)' has some invalid arguments
Error 3 Argument 1: cannot convert from 'Microsoft.SPOT.Hardware.Cpu.Pin' to 'Microsoft.SPOT.Hardware.Cpu.AnalogChannel'



What is wrong?

Thanks

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 September 2011 - 09:29 PM

Hi maara, That is brand new in .NET MF 4.2 RC2. We will be replacing the current AnalogInput classes with the new ones. As a temporary workaround...when you declare your AnalogInputs, use "SecretLabs.NETMF.Hardware.AnalogInput" instead of just "AnalogInput". Chris

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 September 2011 - 09:34 PM

P.S. We plan to extend the AnalogInput class in .NET MF 4.2 so that your existing code will "just work." The only caveat is that the readings will now be Doubles instead of Ints -- so you will need to add (int) in front of the value if you're storing the data as an int... For instance: int reading = (int)analogInput.Read(); Chris

#4 Arbiter

Arbiter

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationBrisbane, Australia

Posted 27 July 2012 - 01:06 AM

Chris, how has this panned out? Should I update my code?

Does this
Microsoft.SPOT.Hardware.AnalogInput(Cpu.AnalogChannel.ANALOG_0)
refer to the same pin as this
SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0)
?
One day, all this too shall parse.

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 July 2012 - 01:13 AM

Hi Arbiter,

Chris, how has this panned out? Should I update my code?

Does this

Microsoft.SPOT.Hardware.AnalogInput(Cpu.AnalogChannel.ANALOG_0)
refer to the same pin as this
SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0)
?

Yes, once we support the new AnalogInput class those will do the same thing. For now, please use the SecretLabs versions.

The plan is to move the Secret Labs PWM and AnalogInput classes to dedicated assemblies. That way they're available for existing applications to use but we also avoid the naming conflicts by defaults.

More on this coming soon...

Chris

#6 zemuss

zemuss

    Advanced Member

  • Members
  • PipPipPip
  • 69 posts

Posted 25 October 2012 - 06:18 PM

Chris, The SecretLabs.NETMF.Hardware name space doesn't include AnalogInput. I am getting the AnalogInput from the Microsoft.SPOT.Hardware and am wondering if that is correct or if not where else should I pull the Class from?

#7 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

Posted 26 October 2012 - 01:16 PM

You need to add a reference to SecretLabs.NETMF.Hardware.AnalogInput and that should get you what you need. Hope this helps.
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#8 zemuss

zemuss

    Advanced Member

  • Members
  • PipPipPip
  • 69 posts

Posted 30 October 2012 - 01:23 AM

I originally added that namespace, and received the following error: "Error 2 The type or namespace name 'AnalogInput' does not exist in the namespace 'SecretLabs.NETMF.Hardware' (are you missing an assembly reference?) C:\Development\Code Examples\Netduino-Aquarium-Controller\Plugin-Temperature\Temperature.cs 5 33 Plugin-Temperature " So it doesn't seem the SecretLabs.NETMF.Harware has AnalogInput namespace.

#9 zemuss

zemuss

    Advanced Member

  • Members
  • PipPipPip
  • 69 posts

Posted 30 October 2012 - 02:25 PM

After upgrading from .NET MF 4.1 to 4.2 you need to remove the references then re-add each reference. THe issue is the path seems to be slightly different. So after re-adding and added this code AnalogInput ain = new AnalogInput(AnalogChannels.ANALOG_PIN_A0); it works.

#10 fileark

fileark

    Member

  • Members
  • PipPip
  • 12 posts
  • LocationNM

Posted 28 November 2012 - 09:41 PM

I tried removing and adding SecretLabs.NETMF.Hardware and SecretLabs.NETMF.Hardware.NetduinoPlus but that did not help. I noticed that I could add a reference in my project for SecretLabs.NETMF.Hardware.AnalogInput so I did which improved things but after that my old analog inputs were ambiguous so I added SecretLabs.NETMF.Hardware. in front of each AnalogInput in the code.

#11 Rashaad

Rashaad

    New Member

  • Members
  • Pip
  • 1 posts

Posted 09 November 2013 - 11:51 PM

Hi maara, That is brand new in .NET MF 4.2 RC2. We will be replacing the current AnalogInput classes with the new ones. As a temporary workaround...when you declare your AnalogInputs, use "SecretLabs.NETMF.Hardware.AnalogInput" instead of just "AnalogInput". Chris

I had to add this reference(SecretLabs.NETMF.Hardware.AnalogInput) in the solution explorer,

and did what you suggested in my code :

 static SecretLabs.NETMF.Hardware.AnalogInput potentiometer =newSecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0);

and it works...

 

 

thanks






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.