DPRG List  

[DPRG] Regarding Serial Programming

Subject: [DPRG] Regarding Serial Programming
From: Robert Jordan rljordan at airmail.net
Date: Mon Feb 14 18:52:09 CST 2005


I'm not familiar with Borland C but my guess is that the
"environment" for the computer is reset to the default
when using the EXE code. When you use the Ctrl+F9
you are still in the environment of the C program so
the computers environment is in what ever state you
have set it up to be.

I assume you are using Microsoft based Op system.
In DOS you tell the PC to change the Com ports settings
by using the MODE command.

MODE COM1,9600, N, 8,1,P
This would set the com1: port for 9600 baud, no parity,
8 data bits, and one stop bit. Leave the P if you have
a printer attached, so it will "wait" on the printer buffer to
clear, vs the software trying once and timing out.
Omit the P for typical ASCII use.

Your Borland software, of your code, is likely doing
some port setup for COM1 that your EXE program
is not doing, or is resetting to default.

Try connecting a terminal or terminal emulator on the
COM1: port and view the differences you get with
simple programs, from inside C and from an EXE file.
Use a modem eliminator pinned out cable so your
port connections are connected correctly.
Or change flow control on software and hardware
to be 'none'. Then connect the TX to RX, RX to TX
and ground to ground between the serial connectors.
You may have to connect RTS to CTS and DSR to DTR and DCD
on each end so the hardware will be happy.

Hope this helps.
Bob Jordan
  -----Original Message-----
  From: dprglist-bounces at dprg.org [mailto:dprglist-bounces at dprg.org]On
Behalf Of suresh N
  Sent: Monday, February 14, 2005 6:15 PM
  To: dprglist at dprg.org
  Subject: [DPRG] Regarding Serial Programming

  Hi friends

  I wanted to know

  "Is there any difference between running a C code from Borland C (using
ctrl+F9) and executing the EXE file for the same source code"

  The problem is :-

  I have an instrument which displays data on its screen. The instrument
also has a serial port. When some instructions in ASCII format are sent to
the instrument from my PC through COM1, it sends the data through its serial
port. I have to receive it through COM1 and continue further processing.

  I have a written a C code to communicate to an instrument through COM1
using BORLAND C editor. When ran from editor (by pressing ctrl + F9 ) the
code works fine. But when the EXE for the same code is executed, the code
doesn't give expected result.

  Help me regarding this

  -Thanks in advance

  Yahoo! India Matrimony: Find your life partner online.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.dprg.org/pipermail/dprglist/attachments/20050214/d90c8e3a/attachment.html

More information about the DPRG mailing list