2

From today, after updating libraries Mono C# on my Raspberry Pi Rev 2 Type B (wheezy), the communication via serial no longer works, it seems to me very strange, because yesterday with the same program written in C # the serial communication worked fine.

To make sure that it was not a hardware problem, I installed "screen" on raspberry and writing the line: sudo screen / dev/ttyAMA0 9600, it can receive data from the serial port, so I think it's a problem of the mono libraries after the upgrade. What do you think? I do not really know what it could be, I have tried everything below. I'll post the code for the test program:

public static SerialPort mySerial = new SerialPort("/dev/ttyAMA0", 9600, Parity.None, 8, StopBits.One);

static void Main(string[] args)
{
    mySerial.Open();
    string readed = "";
    while (true)
    {
        try
        {
            if (true)
            {
                if (mySerial.BytesToRead > 0)
                {
                    readed = mySerial.ReadLine();
                    Console.WriteLine("Ho Letto: " + readed);
                 }
            }
        }
        catch (TimeoutException ex)
        {
            Console.WriteLine("Errore nella lettura");
        }
        finally
        {
            //
        }
    }
}

Thanks for the help that you give me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.