locked
type conversions for netmf RRS feed

  • Question

  • using System;
    using System.Net;
    using System.Net.Sockets;
    using System.Threading;
    using System.IO.Ports;
    using Microsoft.SPOT;
    using Microsoft.SPOT.Hardware;
    using SecretLabs.NETMF.Hardware;
    using SecretLabs.NETMF.Hardware.Netduino;
    
    
    namespace barcode_scanner
    {
        public class Program
        {
            public static void Main()
            {
                           InputPort bs = new InputPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.Disabled);
                
                bool bsState;
    
                if(bs == true)
                {
                    bsState = bs.Read();
                }
            }
    
        }
    }

    I get an error message stating that "Operator '==' cannot be applied to operands of type 'Microsoft.SPOT.Hardware.InputPort' and 'bool' "

    How do i deal with this. Also could anyone please help me in saving data to a memory card for a netduino plus 2 with detailed explanation. Thanks in advance.


    ms

    Monday, April 22, 2013 2:30 PM

Answers

  • Please check your condition

    if(bs.Read())
    {
    bsState = bs.Read();
    }


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    • Marked as answer by ms811 Monday, April 22, 2013 9:09 PM
    Monday, April 22, 2013 6:28 PM

All replies

  • There is no implicit way of comparing an object of type InputPort to a Boolean...

    Why did you add the if-case, i.e. what does "true" mean in this case?

    Monday, April 22, 2013 2:59 PM
  • True means a logic high, a state when there is data on the line. Is there a way to convert explicitly or any other way to deal with this situation.

    ms

    Monday, April 22, 2013 3:17 PM
  • Please check your condition

    if(bs.Read())
    {
    bsState = bs.Read();
    }


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    • Marked as answer by ms811 Monday, April 22, 2013 9:09 PM
    Monday, April 22, 2013 6:28 PM