×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

problem when accessing COM1 with "Peek" & "out" statemen

problem when accessing COM1 with "Peek" & "out" statemen

problem when accessing COM1 with "Peek" & "out" statemen

(OP)
Hey all. I am re-writing an application that is going to access a PINPad device through one of the serial ports. I am having something less than success. By that I mean that the device does not seem to be receiving the data I am sending. I am posting my test-app below, anyone have any ideas on where I went wrong?

Thanks in advance

-=-=-=- BEGIN CODE EXAMPLE -=-=-=-
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'    TestPIN.bas
'    Test program for communicating with a PINPad
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

CLS

DIM PortAdd
DEF SEG = 0
PortAdd = PEEK(&H400) + 256& * PEEK(&H401)    'For COM1
DEF SEG

LOCATE 2, 1
PRINT "PortAdd: ", PortAdd

'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Packet$ = ""

Char$ = CHR$(15)
Packet$ = Packet$ + Char$

Char$ = "0"
Packet$ = Packet$ + Char$

Char$ = "1"
Packet$ = Packet$ + Char$

Char$ = "0"
Packet$ = Packet$ + Char$

Char$ = "1"
Packet$ = Packet$ + Char$

Char$ = CHR$(14)
Packet$ = Packet$ + Char$

'*** Get LRC
Char$ = LRC$(Packet$)
Packet$ = Packet$ + Char$

PRINT "Packet$: ", Packet$
FOR x = 1 TO LEN(Packet$)
     OUT PortAdd, ASC(MID$(Packet$, x, 1))

     Out$ = " " + STR$(ASC(MID$(Packet$, x, 1)))
     PRINT Out$
NEXT x

DEF SEG

END

FUNCTION LRC$ (Packet$)
'****************************************************************************
'  Name:        LRC$                                                        *
'  Purpose:     Calculates and appends the LRC (error check character) to   *
'               the communications packet.                                  *
'                                                                           *
'  On Entry:    Packet$         Communications packet to append LRC char    *
'                                                                           *
'  On Return:   LRC$            Longitudinal Redundancy Check character     *
'****************************************************************************

    FOR x% = 2 TO LEN(Packet$)                          ' Each character
        Calc% = Calc% XOR ASC(MID$(Packet$, x%, 1))     ' Calculate 'XOR'
    NEXT x%                                             ' Next character
    LRC$ = CHR$(Calc%)                                  ' Return LRC

END FUNCTION


-=-=-=-  END CODE EXAMPLE  -=-=-=-

Thought for the day: Beware of Gods who cannot laugh...

RE: problem when accessing COM1 with "Peek" & "out" statemen

(OP)
The method I use to set the port baud, stop-bits, etc is as follows

-=-=-=- BEGIN CODE EXAMPLE -=-=-=-
Open$ = "COM"  + LTRIM$(STR$(Port)) + ": 1200,E,7,1,BIN,CD0,CS0,DS0,OP0,RS,TB2048,RB2048"
OPEN Open$ FOR RANDOM AS #1
CLOSE #1
-=-=-=-  END CODE EXAMPLE  -=-=-=-

The program works just fine when accessing the two ports that are hard-wired into the motherboard. The problem comes when attmempting to access the other ports (com 3&4) that are creted by the PCI serial card.

Thought for the day: Beware of Gods who cannot laugh...

RE: problem when accessing COM1 with "Peek" & "out" statemen

My next question would be; Are you able to use another program such as ProCom+ for DOS on Com 3&4 successfully?
Also, when you boot up the computer, does the BIOS indicate that it sees all four COM ports? I ask this because the BIOS may not be recognizing those ports and your PEEK method is reading this BIOS data area. Another possibility is that your OS (Such as Win95 etc) is reconfiguring the PnP devices so that it no longer matches the info in the BIOS data area.
Try looking in the device manager and comparing the data there to what your program is "peeking at"
If none of the above helps, get a 2nd computer and connect it to the offending port using a null modem cable to monitor what is happening.


 
Kim_Christensen@telus.net
http://www3.bc.sympatico.ca/Kim_Christensen/index.html
 

RE: problem when accessing COM1 with "Peek" & "out" statemen

Oh, it's the COM3 and 4 problem!
QB can't access COM3 and 4 through OPEN, unless
you remap them to COM1 and 2.
http://www.fys.ruu.nl/~bergmann/com3.bas

RE: problem when accessing COM1 with "Peek" & "out" statemen

I'm not sure this is the correct place, but I've been working on this for awhile and cannot discover my error.  Similar to BobTheMad, I've been working on using a pin pad for a non-commerce application (ie using it for simple input) and I'm programming in VB 6.  The problem is I don't know if I have my LRC algorithm incorrect or if it's a problem in the code.

In Bob's ex. he sends:
    chr(15) 0 1 1 0 chr(14)

What I would like to know is what is the valid LRC?  In his algorithm it appears he ignores the "Shift In" byte when calculating the LRC.  Why?  

Also, I'm not even trying to go to an odd port like COM3 or COM4, but COM2.

Thanx for any replies.

tredekka13

PS If anyone would like me to e-mail them a copy of the VB code please e-mail me at tredekka@yahoo.com and I will send it to them yesterday.  I'm very frustrated at this point.

RE: problem when accessing COM1 with "Peek" & "out" statemen

I know it's a old thread, but I'm trying to talk to the Verifone 1000 pinpad and I always get a NAK. So I thought that my LRC maybe wrong. I hope you got it working and can help me out.

Kim Jensen

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close