Communication via serial port from emulator to device

7 views
Skip to first unread message

scm47

unread,
Apr 21, 2010, 5:26:01 AM4/21/10
to
There has been a similar thread some time ago ("Communication with Emulator
via COM port from PC desktop") and I have appended my question there. But as
this is an old thread I assume that my question has perhaps not been seen by
some people who possibly could help me.

I want to do serial communication from an emulator running on the PC to a
real device connected via a serial port. I have taken the code from Jens
Kühner and finally got some response from the port.

I have extended the Emulator with the following code:
public override void SetupComponent()
{
base.SetupComponent();

ComPortToPhysicalPcSerialPort comPort = new
ComPortToPhysicalPcSerialPort();
comPort.ComPortHandle = new ComPortHandle(TransportType.Usart, 2);
comPort.Baudrate = 115200;
comPort.PhysicalPortName = "COM1";
comPort.Handshake = System.IO.Ports.Handshake.RequestToSend;
RegisterComponent(comPort);
}

Here ComPortToPhysicalSerialPort is Jens Kühner's Code.
"COM1" is the physical port of the PC.
And I need "new ComPortHandle(TransportType.Usart, 2);"
because my app uses the "COM2" port.

The code of the app is:
serialPort = new SerialPort("COM2", 115200, Parity.None);
serialPort.Handshake = Handshake.RequestToSend;
try
{
serialPort.Open();
}
catch (Exception ex)
{
Debug.Print(ex.Message);
Debug.Print(ex.StackTrace);
}

When doing this I get the following output:

Exception was thrown: System.ArgumentException

System.IO.Ports.SerialPort::HandlePinReservations
System.IO.Ports.SerialPort::Open

But I don't find anything about HandlePinReservations.
And it doesn't seem to be a problem of the app as it already is running on
real hardware.

Has anyone experienced this too?
And what can I do to get more specific information about this behaviour?
And finally solve the problem?

Martin

Bjorn Claeys

unread,
Sep 16, 2011, 5:22:05 AM9/16/11
to
Hi,

Did you ever find a solution to this problem?
I'm currently making my own emulator and run into the same problem.

Thanks,
Bjorn

> On Wednesday, April 21, 2010 5:26 AM scm47 wrote:

> There has been a similar thread some time ago ("Communication with Emulator
> via COM port from PC desktop") and I have appended my question there. But as
> this is an old thread I assume that my question has perhaps not been seen by
> some people who possibly could help me.
>
> I want to do serial communication from an emulator running on the PC to a
> real device connected via a serial port. I have taken the code from Jens
> K??hner and finally got some response from the port.
>
> I have extended the Emulator with the following code:
> public override void SetupComponent()
> {
> base.SetupComponent();
>
> ComPortToPhysicalPcSerialPort comPort = new
> ComPortToPhysicalPcSerialPort();
> comPort.ComPortHandle = new ComPortHandle(TransportType.Usart, 2);
> comPort.Baudrate = 115200;
> comPort.PhysicalPortName = "COM1";
> comPort.Handshake = System.IO.Ports.Handshake.RequestToSend;
> RegisterComponent(comPort);
> }
>
> Here ComPortToPhysicalSerialPort is Jens K??hner's Code.
> "COM1" is the physical port of the PC.
> And I need "new ComPortHandle(TransportType.Usart, 2);"
> because my app uses the "COM2" port.
>
> The code of the app is:
> serialPort = new SerialPort("COM2", 115200, Parity.None);
> serialPort.Handshake = Handshake.RequestToSend;
> try
> {
> serialPort.Open();
> }
> catch (Exception ex)
> {
> Debug.Print(ex.Message);
> Debug.Print(ex.StackTrace);
> }
>
> When doing this I get the following output:
>
> Exception was thrown: System.ArgumentException
>
> System.IO.Ports.SerialPort::HandlePinReservations
> System.IO.Ports.SerialPort::Open
>
> But I do not find anything about HandlePinReservations.
> And it does not seem to be a problem of the app as it already is running on
Reply all
Reply to author
Forward
0 new messages