PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Unsuccessfull serial communication with CF 2.0

Reply

Unsuccessfull serial communication with CF 2.0

 
Thread Tools Rate Thread
Old 17-01-2006, 09:06 AM   #1
Lonifasiko
Guest
 
Posts: n/a
Default Unsuccessfull serial communication with CF 2.0


Hi,

I must communicate my PDA with a device via serial communication. The
device brings a cable ready for that, and in order to provide a seriaI
port to my PDA, I bought this cable:
http://www.cablematic.com/index.php...=128&pag=2&p=25

Well, I have some specifications from my manufacturer. They are related
for device-PC (not PDA) communication via serial port, but I suppose
they will be the same for device-PDA coomunication. I sum up them:

Baud Rate = 9600 bps Data Bits = 8
Stop Bits = 1 Parity = none
Flow Control = None Com Port = port utilized (I'm trying with "COM1")

And here are another conditions:
1. The computer must assert (apply a positive RS-232 voltage to) RTS
and/or DTR. Either or
both of these signals supply power to the cable circuitry.
2. The computer may leave RTS "open" but may not drive it to a negative
RS-232 level.
3. The computer communications port must be set to 9600 baud, 8 data
bits, no parity, and one
stop bit.

I've been able to open the serial port on COM1, and send a command
specified by the manufacturer (no error indeed) that should wake up the
device, but I'm not seeing any result on the device's screen.
I've carefully followed the manufacturer's specifications and I'm using
CF 2.0 with System.IO.Ports.SerialPort class. This is my code:

-------------------------------------------------------------------------
SerialPort sp = new SerialPort();
sp.BaudRate = 9600;
sp.StopBits = StopBits.One;
sp.Parity = Parity.None;
sp.DataBits = 8;
sp.PortName = "COM1";
sp.RtsEnable = true;
sp.DtrEnable = true;
//sp.Encoding = Encoding.ASCII;
//sp.Handshake = Handshake.None;

try
{
sp.DataReceived += new
SerialDataReceivedEventHandler(this.ReceiveData);
sp.ErrorReceived += new
SerialErrorReceivedEventHandler(this.ErrorInSerialCommunication);
sp.WriteTimeout =
System.IO.Ports.SerialPort.InfiniteTimeout;
sp.Open();
sp.WriteLine("DMP");
MessageBox.Show("Command sent");
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}


private void ReceiveData(Object sender, SerialDataReceivedEventArgs e)
{
MessageBox.Show("Receive Data");
}

-----------------------------------------------------------------------------------------

Hope you can see something that is not letting me communicate properly
with the device.

Thanks very much in advance.

  Reply With Quote
Old 17-01-2006, 09:51 AM   #2
Lonifasiko
Guest
 
Posts: n/a
Default Re: Unsuccessfull serial communication with CF 2.0

Hi again,

from Microsoft's documentarion about SerialPort class:
"Use this class to control a serial port file resource. This class
provides SYNCHRONOUS and event-driven I/O, access to pin and break
states, and access to serial driver properties "

Only synchronous I/O? Asynchronous would not be supported by this
class? I've noticed specification from device's manufacturer also tells
me this:

"The device supports ASYNCHRONOUS, RS-232 communications via the data
port at 9600 baud only.
Data are transferred as 8-bit characters with no parity and one stop
bit. Communication is via three-wire (RS-232
designations of BA, BB, AB) cable."

So I'm seeing an incompatibility right now. Can anybody explain me this
and give me a clear solution?

Thanks.

  Reply With Quote
Old 17-01-2006, 12:44 PM   #3
Guest
 
Posts: n/a
Default Re: Unsuccessfull serial communication with CF 2.0

Does your device support DTR or RTS? Not al UARTs do.

As for the synchronous v. asynchonous, the docs are wrong. RS232 by
definition is asynchronous and I know that the serial classes will not work
for synchronous serial.

-Chris

"Lonifasiko" <mloichate@gmail.com> wrote in message
news:1137488789.672458.46470@g47g2000cwa.googlegroups.com...
> Hi,
>
> I must communicate my PDA with a device via serial communication. The
> device brings a cable ready for that, and in order to provide a seriaI
> port to my PDA, I bought this cable:
> http://www.cablematic.com/index.php...=128&pag=2&p=25
>
> Well, I have some specifications from my manufacturer. They are related
> for device-PC (not PDA) communication via serial port, but I suppose
> they will be the same for device-PDA coomunication. I sum up them:
>
> Baud Rate = 9600 bps Data Bits = 8
> Stop Bits = 1 Parity = none
> Flow Control = None Com Port = port utilized (I'm trying with "COM1")
>
> And here are another conditions:
> 1. The computer must assert (apply a positive RS-232 voltage to) RTS
> and/or DTR. Either or
> both of these signals supply power to the cable circuitry.
> 2. The computer may leave RTS "open" but may not drive it to a negative
> RS-232 level.
> 3. The computer communications port must be set to 9600 baud, 8 data
> bits, no parity, and one
> stop bit.
>
> I've been able to open the serial port on COM1, and send a command
> specified by the manufacturer (no error indeed) that should wake up the
> device, but I'm not seeing any result on the device's screen.
> I've carefully followed the manufacturer's specifications and I'm using
> CF 2.0 with System.IO.Ports.SerialPort class. This is my code:
>
> -------------------------------------------------------------------------
> SerialPort sp = new SerialPort();
> sp.BaudRate = 9600;
> sp.StopBits = StopBits.One;
> sp.Parity = Parity.None;
> sp.DataBits = 8;
> sp.PortName = "COM1";
> sp.RtsEnable = true;
> sp.DtrEnable = true;
> //sp.Encoding = Encoding.ASCII;
> //sp.Handshake = Handshake.None;
>
> try
> {
> sp.DataReceived += new
> SerialDataReceivedEventHandler(this.ReceiveData);
> sp.ErrorReceived += new
> SerialErrorReceivedEventHandler(this.ErrorInSerialCommunication);
> sp.WriteTimeout =
> System.IO.Ports.SerialPort.InfiniteTimeout;
> sp.Open();
> sp.WriteLine("DMP");
> MessageBox.Show("Command sent");
> }
> catch (Exception exc)
> {
> MessageBox.Show(exc.Message);
> }
>
>
> private void ReceiveData(Object sender, SerialDataReceivedEventArgs e)
> {
> MessageBox.Show("Receive Data");
> }
>
> -----------------------------------------------------------------------------------------
>
> Hope you can see something that is not letting me communicate properly
> with the device.
>
> Thanks very much in advance.
>



  Reply With Quote
Old 17-01-2006, 01:07 PM   #4
Lonifasiko
Guest
 
Posts: n/a
Default Re: Unsuccessfull serial communication with CF 2.0

Hi Chris,

Thanks for your interest. What do you mean by UART? This is what I can
tell you:

"supports asynchronous, RS-232 communications via the data port at 9600
baud only.
Data are transferred as 8-bit characters with no parity and one stop
bit. Communication is via three-wire (RS-232
designations of BA, BB, AB) cable."

and.....

"The following conditions must be met:
1. The computer must assert (apply a positive RS-232 voltage to) RTS
and/or DTR. Either or
both of these signals supply power to the cable circuitry.
2. The computer may leave RTS "open" but may not drive it to a negative
RS-232 level.
3. The computer communications port must be set to 9600 baud, 8 data
bits, no parity, and one
stop bit."

Therefore you mean that after knowing RTS or DTR, I would be able with
CF 2.0 SerialPort class to send and receive data via serial port?
I'm using event driven communication like this:

sp.DataReceived += new
SerialDataReceivedEventHandler(this.ReceiveData);

I understand that after sending the specific command I need with Write
or WriteLine(), if device sends me back something, ReceiveData method
should be called.

Thanks very much.

  Reply With Quote
Old 17-01-2006, 01:42 PM   #5
Guest
 
Posts: n/a
Default Re: Unsuccessfull serial communication with CF 2.0

Your device requires voltage on RTS or DTR. I'm saying that the UART used
for the serial port on your device may not support them, and the
manuafacturer therefore would not have run any signals. The port could
still send and receive data, it just can't support the handshaking lines.
You have to check with the OEM.

-Chris

"Lonifasiko" <mloichate@gmail.com> wrote in message
news:1137503277.857846.147960@g49g2000cwa.googlegroups.com...
> Hi Chris,
>
> Thanks for your interest. What do you mean by UART? This is what I can
> tell you:
>
> "supports asynchronous, RS-232 communications via the data port at 9600
> baud only.
> Data are transferred as 8-bit characters with no parity and one stop
> bit. Communication is via three-wire (RS-232
> designations of BA, BB, AB) cable."
>
> and.....
>
> "The following conditions must be met:
> 1. The computer must assert (apply a positive RS-232 voltage to) RTS
> and/or DTR. Either or
> both of these signals supply power to the cable circuitry.
> 2. The computer may leave RTS "open" but may not drive it to a negative
> RS-232 level.
> 3. The computer communications port must be set to 9600 baud, 8 data
> bits, no parity, and one
> stop bit."
>
> Therefore you mean that after knowing RTS or DTR, I would be able with
> CF 2.0 SerialPort class to send and receive data via serial port?
> I'm using event driven communication like this:
>
> sp.DataReceived += new
> SerialDataReceivedEventHandler(this.ReceiveData);
>
> I understand that after sending the specific command I need with Write
> or WriteLine(), if device sends me back something, ReceiveData method
> should be called.
>
> Thanks very much.
>



  Reply With Quote
Old 17-01-2006, 03:48 PM   #6
Lonifasiko
Guest
 
Posts: n/a
Default Re: Unsuccessfull serial communication with CF 2.0

Chris,

I've connected the device to my PC, using COM1 serial port.
I'm able to run HyperTerminal , send commands and see what the device
is returning. The configuration of hyperterminal, as you will know,
it's really simple:
just establish parity, stop bits, flow control, data bits, port name
and baudrate........and works!

I've also built a little example application in Winforms and
ReceiveData event is correctly fired after I've sent a command.
However, the value I read is not the value I expected. In all examples
they say "ReadExisting()" method is enough to read all data. This
method only gives me a "?" character, when I expect al least 20
characters.

Any other good way to read received data?

Thanks.

  Reply With Quote
Old 17-01-2006, 04:21 PM   #7
Joseph Byrns
Guest
 
Posts: n/a
Default Re: Unsuccessfull serial communication with CF 2.0

I think the trouble here is likely that the RTS pin on the PDA is not high
(i.e. does not provide a voltage supply). On the other hand I guess a PC
always provides a voltage to this pin (even though hardware flow control is
not enabled). I don't have the relevant connections to test this.

Judging from what you have written it would seem the other device gets its
power from the RTS pin (RTS is pin 7 at the PDA/PC end). So for you to get
this to work with a PDA you may have to provide your own voltage (using a
battery presumably) to the RTS pin on the other device (infact as the PC RTS
pin connects to CTS on the other device you would need to provide a voltage
to pin 8 on the other device, with ground at pin 5).

HTH


"Lonifasiko" <mloichate@gmail.com> wrote in message
news:1137512909.105991.100760@g49g2000cwa.googlegroups.com...
> Chris,
>
> I've connected the device to my PC, using COM1 serial port.
> I'm able to run HyperTerminal , send commands and see what the device
> is returning. The configuration of hyperterminal, as you will know,
> it's really simple:
> just establish parity, stop bits, flow control, data bits, port name
> and baudrate........and works!
>
> I've also built a little example application in Winforms and
> ReceiveData event is correctly fired after I've sent a command.
> However, the value I read is not the value I expected. In all examples
> they say "ReadExisting()" method is enough to read all data. This
> method only gives me a "?" character, when I expect al least 20
> characters.
>
> Any other good way to read received data?
>
> Thanks.
>



  Reply With Quote
Old 17-01-2006, 04:55 PM   #8
DickGrier
Guest
 
Posts: n/a
Default Re: Unsuccessfull serial communication with CF 2.0

Hi,

To follow up on what Joseph said, one problem may be that the RTS output
from your device has both too low a voltage level AND cannot drive the
current required. If you attempt to power an external device from a PPC
serial port (DTR and RTS), often you will fail. There simply isn't enough
power available on the output pins. Thus, you have to provide a separate
power supply for such devices.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition, ISBN 1-890422-28-2, Mabry Publishing (391 pages, includes CD-ROM).
July 2004.
See www.hardandsoftware.net for details and contact information.


  Reply With Quote
Old 17-01-2006, 06:36 PM   #9
Markus Humm
Guest
 
Posts: n/a
Default Re: Unsuccessfull serial communication with CF 2.0

Hello,

there are two things, one already mentioned:

1. the RS232 of the PDA might not supply any voltage, e.g. Acer n30
doens't supply any voltage (which is bad habbit), it "steals" it from
the PC.

2. often the cable for the pda rs232 is crossed, since a rs232
connection of two PCs (a PDA is like a PC in this case) requires a
crossed cable, but other devices (like a serial mouse) requires a
straight cable. "de-crossers" are available for purchase.

Greetings

Markus
  Reply With Quote
Old 18-01-2006, 06:59 AM   #10
Lonifasiko
Guest
 
Posts: n/a
Default Re: Unsuccessfull serial communication with CF 2.0

Hi folks, thanks for your replies.

I'm afraid I'm quite lost in the hardware issues you are mentioning,
talking about pins, voltages and so on ;-)

>From your replies, I understand the following:

1. The CompactFlash cable I've purchased provides a serial port for the
PDA but the problem is not here. The problem is that the PDA does not
provice any voltage to RTS or DTR pins of the CompactFlash slot.
2. You tell me to supply power to this pin externally. How? A battery
attached to the PDA? Tell me please (although I don't like the idea
very much).
3. The PDA I'm trying with is an iPAQ h5500. Are iPAQs so special for
serial communication?
4. I don't know about crossed cables and de-crossers. Could you give me
a good link based on the CompactFlash cable I mention above in the
post?
5. The problem could be because of the manufacturer's cable?

If I do not supply voltage to the mentioned pin, isn't there another
solution? Just I won't be able to achieve satisfactory serial
communication? I can't believe my eyes
I thougth serial communication did not depend so much on the PDA and on
the external device. I thougth the Compact Flash was the only thing I
need.

Thanks very much.

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off