Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COM port issue

Status
Not open for further replies.

csallee

Technical User
Dec 4, 2002
12
0
0
US
Hello everyone,
I am the project lead for a MS Foxpro 2.6 to SQL 2K upgrade and I am having a HW issue with some COM ports. I was hoping that you guys could help. I have the Compaq EVO desktops which come with 2 COM ports. I am running a homegrown application that we will use to process product. I have a scale, scanner and a Datamax label printer hooked up to the PC. I wanted to use LPT1 for my printer, but our program does not have that option (I didn't write the program), so I had to buy an additional COM card and hook it up that way. The problem I am having now is that if I exit the program and re-enter it I get a "init:port already in use" error. the only way I have found to fix it is to shutdown, unplug my scale and boot back up. The employees are not going to be able to have this option when it is deployed. Note: the scale sends data 100% of the time to the program. I need to figure out how to be able to shut off the port when I exit the program and have it reconnect when I open it. I have gone into device manager and verified that the ports are working correctly, but I could figure out how to shut them off when I exit. Any help would be GREATLY appreciated as the project is basically on hold until I can get this resolved.
Thank you in advance.
 
Hello csallee,
Can you post here the comm ports each device is using and the Base addresses and Irq's?
ie: Scanner
Comm1
03f8
Irq4

Also, does the pc have a modem and is it stll being used?
 

CLOSECOMM()
-----------

Purpose
-------

The CloseComm() function closes the specified communications device and frees any memory allocated for the device's transmission and receiving queues. All characters in the output queue are sent before the communications device is closed.

Function Syntax
---------------

CloseComm(<comm_id>)


<comm_id> Specifies the device to be closed. The OpenComm() function returns this value. In the example below this is the variable com1.

Returns
-------

The return value is zero if the function is successful. Otherwise, it is less than zero.

Code Example
------------

The following code example uses the WriteComm() and CloseComm() functions and FOXTOOLS.FLL to write to and close COM1. (This example can be found in FOXPROW\GOODIES\FOXTOOLS\DIALER.PRG.)

*-------------------- dialer.prg ------------------------
* Sample program to output to comm port
* Uses FoxTools library for generic DLL access

SET LIBRARY TO SYS(2004)+&quot;foxtools.fll&quot; ADDITIVE

opencomm = REGFN(&quot;OpenComm&quot;, &quot;CII&quot;, &quot;I&quot;)
writecomm = REGFN(&quot;WriteComm&quot;, &quot;ICI&quot;, &quot;I&quot;)
closecomm = REGFN(&quot;CloseComm&quot;, &quot;I&quot;, &quot;I&quot;)

com1 = CALLFN(opencomm, &quot;COM1:&quot;, 100, 100)
s = &quot;ATDT 5551212&quot; + chr(13)
=CALLFN(writecomm, com1, s, len(s))

WAIT WINDOW &quot;Press any key to hang up&quot;
s = &quot;ATH0&quot; + chr(13)
=CALLFN(writecomm, com1, s, len(s))

=CALLFN(closecomm, com1)

RELEASE LIBRARY SYS(2004)+&quot;foxtools.fll&quot;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top