Main Site Documentation

FEZ Cerberus RS232 RTS/CTS Handshake


#1

I am having a problem with hardware handshaking using socket 2. To help resolve the problem I have written a simple test program. I can see data coming out of the TX pin and read it correctly; the output for the TX pin can be disabled/enabled by toggling the CTS pin as expected. What I cant see is the RTS pin changing state using an oscilloscope: this is cause of my problem. I need to use the RTS line to control data direction on a RS485 (ADM485) device. I have tried a 4k7 pull-up resistor to see if the line is been driven low since this is its state when running the program: the line is been driven low.
Can anybody help!

using System;
using Microsoft.SPOT;
using System.IO.Ports;

using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace SerialTestApp.Classes
{
class TestRs232
{
private Joystick _JoyStick;
private RS232 _RS232;
private GT.Mainboard _Mainboard;

    internal TestRs232(Gadgeteer.Mainboard mainBoard, RS232 comsPort,Joystick joystick )
    {
        _RS232 = comsPort;
        _JoyStick = joystick;
        _Mainboard = mainBoard;
        _RS232.Initialize(9600, GT.Interfaces.Serial.SerialParity.None, GT.Interfaces.Serial.SerialStopBits.One, 8, GT.Interfaces.Serial.HardwareFlowControl.Required);
        _RS232.serialPort.Open();
        _JoyStick.JoystickPressed += new Joystick.JoystickEventHandler(_JoyStick_JoystickPressed);
        _JoyStick.JoystickReleased += new Joystick.JoystickEventHandler(_JoyStick_JoystickReleased);
        _Mainboard.SetDebugLED(_RS232.serialPort.UsingHardwareFlowControl);
    }

    void _JoyStick_JoystickReleased(Joystick sender, Joystick.JoystickState state)
    {
        _Mainboard.SetDebugLED(false);
    }

    void _JoyStick_JoystickPressed(Joystick sender, Joystick.JoystickState state)
    {
        SendData();
        _Mainboard.SetDebugLED(true);
    }


    private void SendData()
    {
        byte[] data = new byte[] { 0x01,0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };

        _RS232.serialPort.Write(data);
    }
}

}


#2

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)

#3

Thanks Ill remember that!

using System;
using Microsoft.SPOT;
using System.IO.Ports;

using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;


namespace SerialTestApp.Classes
{
    class TestRs232
    {
        private Joystick _JoyStick;
        private RS232 _RS232;
        private GT.Mainboard _Mainboard; 

        internal TestRs232(Gadgeteer.Mainboard mainBoard, RS232 comsPort,Joystick joystick )
        {
            _RS232 = comsPort;
            _JoyStick = joystick;
            _Mainboard = mainBoard;
            _RS232.Initialize(9600, GT.Interfaces.Serial.SerialParity.None, GT.Interfaces.Serial.SerialStopBits.One, 8, GT.Interfaces.Serial.HardwareFlowControl.Required);
            _RS232.serialPort.Open();
            _JoyStick.JoystickPressed += new Joystick.JoystickEventHandler(_JoyStick_JoystickPressed);
            _JoyStick.JoystickReleased += new Joystick.JoystickEventHandler(_JoyStick_JoystickReleased);
            _Mainboard.SetDebugLED(_RS232.serialPort.UsingHardwareFlowControl);
        }

        void _JoyStick_JoystickReleased(Joystick sender, Joystick.JoystickState state)
        {
            _Mainboard.SetDebugLED(false);
        }

        void _JoyStick_JoystickPressed(Joystick sender, Joystick.JoystickState state)
        {
            SendData();
            _Mainboard.SetDebugLED(true);
        }


        private void SendData()
        {
            byte[] data = new byte[] { 0x01,0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };

            _RS232.serialPort.Write(data);
        }
    }
}


#4

You can edit your original post (pencil button). Select your code and press grey “1010” button. All it does is wraps selected text with code tags.


#5

Much better. I am not exactly 100% sure, but I remember seeing something about hardware handshaking not supported in current firmware. I would also search for threads that have RS485 you might find something usefull there:

http://www.tinyclr.com/forum/search?q=RS485

Welcome to the forum!


#6

Thank’s I’ll take a look!


#7

We did improve this a bit but handshaking does not work perfectly. The smaller memory caused some issues

This maybe visited in the future but it is a low priority item.

Welcome to the community.


#8

Thanks. Thats save me some time: Ill look at other solutions.