delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/30/15:43:33

Message-ID: <F821915ECD30D3119CC30050042676032017E8@SPZMG01>
From: Poonam Jain <poonam DOT jain AT seepz DOT tcs DOT co DOT in>
To: djgpp AT delorie DOT com
Subject: Problem in printing by the printer attached to COM3
Date: Fri, 30 Jul 1999 15:00:21 +0530
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)
Reply-To: djgpp AT delorie DOT com

Hi

Details of the program  to deal with COM ports. 

Description: In the current setup the printer to the COM3 port. The sample
code opens COM3 port and write characters  to it using COMWriteChar()..
COMDetect() is used to find the H/W details of this port. Port is closed
using COMPortClose().

Problem: Code is exiting successfully but nothing is being printed by the
printer.( which is IBM_SURE Printer is attached to COM3)

Details of IBM_SURE Printer :

2 Mode :           Xon/Xoff     DTR/DSR

1 Baud Rate :  19.2 KB        9.6 KB

 Sample Code:

#include<stdio.h>
#include <com.h>


char *COMChipsets[5] =
{
  "8250",
  "16450",
  "16550",
  "16550A",
  "N/A"
};

main()
{

int nError,i;
int nIRQ, nAddress;
int nChip;


if ((nError = COMPortOpen(COM3, 9600, 8, 'N', 1, 0, NULL)) != 0)
 {
    printf("Error #%d trying to open COM3\n", nError);
    return;
  }
  printf(" Port COM3 is opened successfully \n");


  printf("     chipset    io   IRQ\n");
  printf("------------------------------------\n");

  nChip = COMDetect(i);
]
  COMGetHardwareParameters(COM3, &nIRQ, &nAddress);
  printf("COM%d %-6s    %4x  %d\n", COM3,
  COMChipsets[nChip - 1], nAddress, nIRQ);
  

for( i=0; i < 20; i++)
{
  if (COMWriteChar(COM3, 's', NULL) != 0)
  {
    printf("Buffer overflow trying to write to COM3\n");
    return;
  }
  delay(200);
}
 printf("Character is printed on the port \n");
 COMPortClose(COM3);
}

Output of the code:
Port COM3 is opened successfully

chipset    io   IRQ
-----------------------------------
COM3    16550A  3e8  4

Character is printed on the port

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019