Shop OBEX P1 Docs P2 Docs Learn Events
Windows Serial Port Buffers help needed — Parallax Forums

Windows Serial Port Buffers help needed

william chanwilliam chan Posts: 1,326
edited 2009-07-31 02:05 in General Discussion
Help! Any MSDN experts out there!

I opened a classic COM port (COM1) using

ComID = CreateFileA(ComName,generic_read + generic_write,0,0,open_existing,0x80,0)

and it opened successfully at 19.2k baud.

I send a character from the PC running Windows XP using

TransmitCommChar(ComID,Ch)

it sends successfully to the Propeller.
The problem is that I have to pace the transmit of chars with a 10ms delay in between or some chars will be lost.
I tried all kinds of buffering using

SetupComm(ComID,64,64)

but it can't seem to properly buffer the transmission. ( slow pacing is still required )
Receiving characters from the Propeller seems to be buffered well.

What is the problem?

Thanks a million.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my

Comments

  • davejamesdavejames Posts: 4,047
    edited 2009-07-30 14:23
    William,

    What, then, about the Propellor side of things? If you have to pace the xmission from the serial port to the Prop, it sounds like the Prop is having "difficulty" in accepting the transmission.

    I'm not familiar with the Prop...does it have a dedicated serial port? If so, does it have a buffer? Is 19.2k baud too fast? Etc. In other words, what are the characteristics of the Prop serial port?

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Instead of:

    "Those who can, do.· Those who can't, teach." (Shaw)
    I prefer:
    "Those who know, do.· Those who understand, teach." (Aristotle)
    ·
  • Computer Geek 101Computer Geek 101 Posts: 179
    edited 2009-07-30 14:29
    William,
    · What serial object are you using on your Prop?· The simple_serial has no buffer.· The FullDuplexSerial has a buffer and I have not had any problems using VS 2008 to do comms with a prop.
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-07-30 14:38
    William

    I'd not call myself an msdn expert, but here's what I'd try:

    First, if I read what you've said correctly, it does work if you slow down the baud rate?

    Are your cables correctly wired ? (You might be attempting hardware handshaking without knowing it).

    I assume you've tried making the prop buff bigger?

    - H

    [noparse][[/noparse]EDIT: Well, my post hit after your first several replies --- looks like we're all asking about the same, eh? ]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • David BDavid B Posts: 592
    edited 2009-07-30 14:54
    As far as I know, there is no way to simply add a delay of this magnitude between character sending in the PC serial driver itself. "stop bits" are the traditional way to add delay, but nowhere as great as the delay you're looking for.

    I'm thinking that your options may be -

    1. fix the reason for needing the pacing. This is a relatively slow rate; why is pacing needed?

    2. implement either software or hardware handshaking

    3. use a slower baudrate

    4. have the sending program itself implement the delay between individual character sends
  • william chanwilliam chan Posts: 1,326
    edited 2009-07-30 17:28
    I am using FullDuplexSerial with 16 bytes buffer for both Tx and Rx.
    I am quite sure the buffering at the Propeller side is working because if the Propeller is busy with some things, it still can come back and process in the received chars a few seconds later.

    David,

    The Windows Application that I wrote is actually doing that, adding delays of 10ms between calls to TransmitCommChar(ComID,Ch).
    If I remove the delays, chars gets lost.

    The same problem exists at 9600 baud.
    I don't understand why the pacing is needed either.
    I am using the 2 transistor circuit as described in the Propeller datasheet.

    CounterRotatingProps,

    It works at 19.2k and 9600 bauds but only with pacing.
    There are only 4 wires, tx, rx, dtr, and gnd.
    Pin 6 and 7 on the 9 pin comm port connector are shorted.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.fd.com.my
    www.mercedes.com.my
  • David BDavid B Posts: 592
    edited 2009-07-30 18:00
    Maybe the best next step would be for you to post your entire propeller program, maybe in the propeller discussion area instead of the sandbox. I'll bet you'll get plenty of suggestions for different ways to manage the character reception to help fix this problem.
  • william chanwilliam chan Posts: 1,326
    edited 2009-07-30 23:44
    The problem is very likely at the Windows end, not the Propeller end as described earlier.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.fd.com.my
    www.mercedes.com.my
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-07-31 00:11
    Have you tried looping back with a null-modem cable into another serial port? Have two terminals talk back and forth.

    I'd be *very* surprised if it was a windows problem. A library problem would also be unlikely.

    Which version of the OS and SP are you on, and what are you compiling/scripting with?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • william chanwilliam chan Posts: 1,326
    edited 2009-07-31 00:22
    Windows XP SP2 and compiling with Visual Prolog 5.2
    I will try the Null modem suggestion.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.fd.com.my
    www.mercedes.com.my
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-07-31 00:23
    XP home or Pro?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • william chanwilliam chan Posts: 1,326
    edited 2009-07-31 02:05
    Pro.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.fd.com.my
    www.mercedes.com.my
Sign In or Register to comment.