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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open com function

Status
Not open for further replies.
May 10, 2001
5
US
I'm trying to establish communication through com port 1 on a motherboard based port. The address for the port has been changed in BIOS to 2f8 because there is only one available serial out on this machine, thank you e-machine :( I am running ms-dos 5.0 on this machine and am using QB ver. 4.5. Here is the code.

CLS

' define com 2 segment
com2 = PEEK(&H402) + 256 * PEEK(&H403)

POKE &H402, com2 AND 255
POKE &H403, com2 \ 256


INPUT "what is the cut length in inches (ex. 62.25)"; length
INPUT "how many cuts on this piece of stock"; quantity
tsteps = length * 2048
skurf = 7000
CLS
PRINT "length:"; length; "x 2048 steps/inch ="; tsteps
FOR DELAY = 1 TO 50000
NEXT DELAY

CLS
PRINT "opening com port for transfer..."
OPEN "com2:9600,n,8,1" FOR RANDOM AS #1
PRINT #1, "XE1"
PRINT #1, "XD1"

(removed filler material)


CLOSE #1
CLS

The problem is that any time I run the program I recieve a "device time out" on the "open com" statement. Does anyone have a sure-fire way to access this port. Thanks in advance!
 
Ooops, posted the old code file. Actually reads:

CLS

' define com 2 segment
com1 = PEEK(&H402) + 256 * PEEK(&H403)

POKE &H402, com2 AND 255
POKE &H403, com2 \ 256


INPUT "what is the cut length in inches (ex. 62.25)"; length
INPUT "how many cuts on this piece of stock"; quantity
tsteps = length * 2048
skurf = 7000
CLS
PRINT "length:"; length; "x 2048 steps/inch ="; tsteps
FOR DELAY = 1 TO 50000
NEXT DELAY

CLS
PRINT "opening com port for transfer..."
OPEN "com1:9600,n,8,1" FOR RANDOM AS #1
PRINT #1, "XE1"
PRINT #1, "XD1"
 
You are peeking into variable com1, but but poking from variable com2.

Is that the fault, or was it a slip writing out the thread?
 
You are poking com2 AND 255, but you have not given com2 a value.

I dont see your problem. If you OPEN COM1, QB should look for the port address in &h400 and &h401. Are you saying the address there is wrong?
 
The reason I put the Peek and Poke statement in originally was because the "open com1" statement by itself was giving me a "device timed out" notice. I hoped that by peeking to the com 1 and then redirecting to com 2 addresses, I could use BIOS to access the port and avoid a time out.
 
If you want to swap port1 and 2 addresses,or poke something else into them, try this:

DEF SEG =&h40
a0%=PEEK(0):a1%=PEEK(1):a2%=PEEK(2):a3%=PEEK(3)

They should normally be 248, 3, 248, 2 respectively. The 248,3 is for port1, and 248,2 is for port 2.

To put port 2 address into the port1 slot (or any other address):

POKE(0)a2%:pOKE(1)a3%

On a much earlier machine I had, QB would wipe the addresses from Bios as soon as I had opened the port. If I closed the com channel and tried to reopen it, I couldnt. I had to switch off and reboot. I cured the problem by PEEking and saving to a file. Next time I opened the channel, I read from the file. Just a thought. If you have an unusual Com1 address that might just be happening.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top