Announcement

Collapse
No announcement yet.

HELP COM programming

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Kurt Schultz
    replied
    Originally posted by Taksios Taxiou:

    A$ = CHR$(1)+"Z00"+CHR$(2)+"AA"+CHR$(27)+" b"+STR$(Y)+CHR$(4)

    [/B]
    edited the quote for some brevity.
    gonna beat a dead horse, even though I checked the date$.

    as a side note, the above-quoted line can be reduced to a concantenation of three string functions:
    A$ = CHR$(1,90,48,48,2,65,65,27,32,98) + STR$(Y) + CHR$(4)

    i'm not sure if this would increase the speed of execution any, but it might


    ------------------


    [This message has been edited by Kurt Schultz (edited August 26, 2003).]

    Leave a comment:


  • Mike Burgett
    replied
    Heh, Guess I should check date$ before I post




    ------------------
    Michael Burgett

    Leave a comment:


  • Aldo Cavini
    replied
    Mike,

    I also had ideas similar to yours, but I noticed this forum was started on november 2002. I'm wondering, may be Taksios solved his problem a long time ago...

    ------------------

    Leave a comment:


  • Mike Burgett
    replied
    Taksios,

    I recognize this statement:

    A$ = CHR$(1)+"Z00"+CHR$(2)+"AA"+CHR$(27)+" b"+STR$(Y)+CHR$(4)


    This is a statement for the Alpha Protocol. I have plenty of
    experience with programming these signs in PowerBasic 3.5. In fact
    I am Inputing from one Comm port and outputing thru another. I have an
    RS232 Bar Code Scanner on one Comm and the display on the other.

    OPEN "COM1:9600,N,8,1,RS,CS,DS" FOR INPUT AS #1 'open com to card reader
    OPEN "COM2:9600,E,7,,CS,DS,CD" FOR OUTPUT AS #2 'open com to display board


    I use ON COMM(1) to poll the com port for activity. I then use INPUT #1 to
    retrieve the data and assign it to a variable. The variable is then easily
    manipulated and then use PRINT #2 to send the data.


    Let me know if you would like any more help. I have the Apha Protocol in a
    nice Excel spreadsheet (Thanks to Mark Thornhill). I also have some code that
    I could share if you like.

    ------------------
    Michael Burgett

    [This message has been edited by Mike Burgett (edited July 18, 2003).]

    Leave a comment:


  • Lance Edmonds
    replied
    Originally posted by Donald Darden:
    The problem is DOS' COMM support (or lack thereof).. While a PC
    can natively support up to four COMM ports (Com1 through COM4),
    whenever you open up a new COM port, DOS will no longer react or
    work with the COMM port that was previously opened. So if you
    open COM1, then COM2, you cannot get any responxe from COM1.
    Turn it around and open COM1 last, and COM2 doesn't work.
    Mike, that is an unusually strange claim that really needs qualification. First, PB/DOS has no such limitations.

    In fact, to be honest, I've never ever seen such an effect in a system that is configured correctly and does not have any hardware conflicts (although I have never used MS BASIC for serial I/0 as you go on to mention, so I guess you could be referring to a MS BASIC "bug"?).

    In any case, I'll repeat it just to be perfectly clear to anyone lurking here: PB/DOS has no such limitation, nor does it have any "requirement" for a driver to be present to use COM1 through COM4, either synchronously or asynchronously.

    The reason that PB/DOS has no such problems is because PB/DOS directly controls the serial port {UART} itself. No external software is required.

    The problem is strickly with the native COM driver software.
    MSDOS really has no need for a native "serial driver" (although some "basic" support for port redirection was provided through the MODE utility), so I would suggest that this comment should be refer to "proprietary serial drivers" rather than "native serial drivers".

    For example, in the case of 3rd-party serial ports that interface to the PC via the PCI buss or through a USB port, then the scenario is completely different as you are dealing with proprietary hardware/software, rather than standard devices, ports, and interrupts.



    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Donald Darden
    replied
    Technically, you should be able to do just what you diescribe.
    However, in DOS, it isn't possible, without a bit of help.

    The problem is DOS' COMM support (or lack thereof).. While a PC
    can natively support up to four COMM ports (Com1 through COM4),
    whenever you open up a new COM port, DOS will no longer react or
    work with the COMM port that was previously opened. So if you
    open COM1, then COM2, you cannot get any responxe from COM1.
    Turn it around and open COM1 last, and COM2 doesn't work.

    The problem is strickly with the native COM driver software.
    You can find other software that works correctly. Now as I
    recall, PB/DOS provides its own serial port drivers, which
    should work as you describr -- input from one port, output to
    another, and vice versa. If you were using QBASIC or QuickBASIC,
    I would say Give it Up!. MS BASIC's only support COM1 and COM2
    for a start. And with the DOS native drivers, you can't even get
    9600 baud down the pipe. There is no need for the two ports to
    be looped back to each other externally (I guess some people
    thought you wanted a loop-around arrangement, which would take a
    null modem cable to make work). But there are signalling
    conventions that have to be observed, such as DSR (Data Set
    Ready) that are covered in any good modem handbook. The fact is,
    several signals have to either be there, or you have to configure
    the port and device at the other end to ignore them. So it is no
    walk in the park to work out all the particulars. But it can be
    done.

    ------------------
    Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

    Leave a comment:


  • John Twomey
    replied
    [QUOTE]Originally posted by Taksios Taxiou:
    [B]Dear friends...

    btw -

    the 'wayout' should be as follows
    don't know how I managed smilies here !

    wayout:
    print "closing com ports and exiting"
    close #1rint "COM1 CLOSED"
    close #1:Print "COM2 CLOSED"
    end


    ------------------
    John T

    Leave a comment:


  • John Twomey
    replied
    to connect the 2 ports com1 and 2 - like you want to
    1. Use a null modem cable
    2. In your open com statement - use like this
    open "com1:9600,n,8,1,rs,cs,cd,ds" as #1

    when writing your program open both ports together

    small sample prog
    -----------------
    cls
    open "com1:9600,n,8,1,rs,cs,cd,ds" as #1
    open "com2:9600,n,8,1,rs,cs,cd,ds" as #2
    do
    print ' prints a blank line
    input "Enter your word";a$ 'asks you for a word
    print 'prints a blank line
    if a$="exit" then goto wayout 'goes to wayout routine
    print "sent ";a$;" from com1 to com2" 'tells you whats going on
    print #1,a$ 'sends the word you entered to com1
    delay 1 ' a 1 second delay - this is up to you
    if loc(2) then input #2,b$ else goto nocom 'input received data
    print "received ";b$;" from com1" 'tells you whats going on
    print 'prints a blank line
    if b$="word" then let c$="drow" else let c$="not what I wanted"
    'if you entered 'word' then it sends 'drow' back
    'set all your conditions now !
    print #2,c$ 'sends the reply
    print "sent ";c$;" from com2 to com1"
    if loc(1) then input #1,d$ else goto nocom
    print "received ";d$;"from com2"
    loop

    wayout:
    print "Closing com ports and exiting"
    close #1 rint "closed com1"
    close #2 rint "closed com2"
    end

    nocom:
    cls
    print "Nothing received ............ closing ports"
    goto wayout

    **************************************************

    I hope this helps a bit - you can set the 'words' you want to
    send etc - rather than asking for a word as I have done(above).

    You can set the conditions i.e. the replies to send back
    as I have done for the word - 'word' above.

    If this is not what you want - You can email me with the exact
    way you want to do it - as it is not very clear - what you want
    to do..

    John T

    ------------------
    John T

    Leave a comment:


  • Mike Luther
    replied
    Why can't one just connect the two ports to whatever they connect
    to externally.

    Then just buffer the data from COM2 as input data and then cross
    write it to COM1 as output data? You'll have to closely sync the
    buffer read-write sizes to do this. As well, single byte stuff does
    not work very well in some growed up operating systems that can't
    let you perform direct hardware read/writes, one might suppose.

    But gee.. it's only data in and data out. Your program is just a
    holding pen for the fabled data cows, no?

    ------------------
    Mike Luther
    [email protected]

    [This message has been edited by Mike Luther (edited November 28, 2002).]

    Leave a comment:


  • Mel Bishop
    replied
    I don't see how that's possible. To send data from COM2 directly
    to COM1, you would need a short null modem cable connecting the
    two ports. If you have that cable installed, how would you
    connect COM2 to another external device?

    I think your best bet would be to input the data from COM2,
    store it in a temporary file, then reprogram the sub-routine
    that used to poll COM1 to read the file and do whatever
    you want with it.


    ------------------


    [This message has been edited by Mel Bishop (edited November 28, 2002).]

    Leave a comment:


  • Taksios Taxiou
    started a topic HELP COM programming

    HELP COM programming

    Dear friends

    I am am trying to programm the com1 & com2. Read from com2 some ascii word updating each sec
    and send it to com1 in a specific format. I ve written the part for com1
    I wonder how i could directly send input from com2 to a variable
    and send it to com1. The com1 progr is very simple

    20 OPEN "COM1:9600,E,7,,CS,DS,CD" AS #1
    30 CLS
    40 FOR X=1 TO 20 : PRINT#1, CHR$(0);:NEXT
    50 A$ = CHR$(1)+"Z00"+CHR$(2)+"AA"+CHR$(27)+" b"+STR$(Y)+CHR$(4)
    60 PRINT #1, A$
    70 PRINT:PRINT" ";Y

    I want the Y to be imported from com2 every sec.Should I try
    to assign directly y-> com2 input? is it possible and what is the format ?
    Thnx for the time!



    ------------------
Working...
X