Announcement

Collapse
No announcement yet.

COMM query

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

  • Adrian C Aitken
    replied
    clearing the break - dunno, I could only borrwo a router for the weekend and since I've got something that works thats it until next weekend!
    I'll try to write the escape part but I use PB at home and my test routers at work (with everyone using it to go on the internet so I wouldn't be popular trashing the configuration !!!!)

    Regards

    Adrian Aitken

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

    Leave a comment:


  • Lance Edmonds
    replied
    Thanks!

    BTW, does clearing the break allow PB's COMM to continue working again, as per my last message? It is crucial that the break is cleared otherwise nothing is able to be sent through the port again.

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

    Leave a comment:


  • Adrian C Aitken
    replied
    Lance , heres the first part of a function - hopefully it explains itself
    You can comment out the StatusMsg (just displays message on label) and WaitforRouter (just sits there waiting for passed string to appear).

    Regards

    Adrian Aitken

    Code:
    CALLBACK FUNCTION btnRebuild() AS LONG
    
    DIM ff AS LONG  , lngAPI AS LONG
    
           MSGBOX "Switch off the router for 5 seconds," + $CRLF + "and press 'OK' after you have" + $CRLF + "switched the router back on." , %MB_OK , "Important"
    
           ff = FREEFILE
           ON ERROR RESUME NEXT
           ERRCLEAR
           COMM OPEN "COM1" AS #ff
           IF ERR <> 0 THEN
              IF ERR=70 THEN
                 MSGBOX "Please switch the router on" + $crlf + "and ensure the BLUE cable" + $crlf + "is attached to the router" + $crlf + "and your PC." , %MB_ICONEXCLAMATION , "Error"
                 EXIT FUNCTION
              END IF
              MSGBOX "Error opening COM1. Please re-try" + $crlf + "Error Code is " + STR$(ERR) , %MB_ICONEXCLAMATION , "Error"
              EXIT FUNCTION
           END IF
           COMM SET #ff, BAUD     = 9600   ' 9600 baud
           COMM SET #ff, BYTE     = 8      ' 8 bits
           COMM SET #ff, PARITY   = %FALSE ' No parity
           COMM SET #ff, STOP     = 0      ' 1 stop bit
           COMM SET #ff, TXBUFFER = 2048   ' transmit buffer
           COMM SET #ff, RXBUFFER = 4096   ' receive buffer
    
           StatusMsg "Waiting for router..."
           WaitForRouter ff,"###",1
           StatusMsg "Sending Break command..."
           lngAPI= FILEATTR(ff,2)
           EscapeCommFunction lngAPI,%SETBREAK  'no GPF
    '      COMM SET #ff,BREAK = 1          ' GPFed every time
    '      MSGBOX "Do you get here?"       ' never popped up
    
           COMM CLOSE #ff                  ' needed because of API call
           StatusMsg "ReOpening Comm port"
           ff = FREEFILE
           ON ERROR RESUME NEXT
           ERRCLEAR
           COMM OPEN "COM1" AS #ff
           IF ERR <> 0 THEN
              IF ERR=70 THEN
                 MSGBOX "Please switch the router on" + $crlf + "and ensure the BLUE cable" + $crlf + "is attached to the router" + $crlf + "and your PC." , %MB_ICONEXCLAMATION , "Error"
                 EXIT FUNCTION
              END IF
              MSGBOX "Error opening COM1. Please re-try" + $crlf + "Error Code is " + STR$(ERR) , %MB_ICONEXCLAMATION , "Error"
              EXIT FUNCTION
           END IF
           COMM SET #ff, BAUD     = 9600   ' 9600 baud
           COMM SET #ff, BYTE     = 8      ' 8 bits
           COMM SET #ff, PARITY   = %FALSE ' No parity
           COMM SET #ff, STOP     = 0      ' 1 stop bit
           COMM SET #ff, TXBUFFER = 2048   ' transmit buffer
           COMM SET #ff, RXBUFFER = 4096   ' receive buffer
    
           WaitForRouter ff,"mon" ,0
           StatusMsg "Now resetting..."
            ...etc
    
    END FUNCTION
    ------------------

    Leave a comment:


  • Lance Edmonds
    replied
    Adrian, I'll check with R&D on the COMM SET BREAK issue... you wouldn't have some sample code that shows up the GPF by any chance? (saves me writing a test app from scratch to test with )

    I don't have a copy of WIN32.HLP with me right now (I'm not at the office), but if I recall correctly, if you use the EscapeCommFunction to use the SETBREAK condition, you have to follow it with a CLRBREAK too, with an appropriate delay between.

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

    Leave a comment:


  • Adrian C Aitken
    replied
    hi Lance, the COMM SET #hComm&, BREAK = 1 GPFed my Win98SE PC continually (having to reboot often!) with Invalid Page Fault in module <>.
    The API call EscapeCommFunction(hndl&,%SETBREAK) worked but then stopped DDT COMM working so I had to shut the port and reopen it again.

    Thanks for your help

    Adrian Aitken

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

    Leave a comment:


  • Lance Edmonds
    replied
    According to my "Data and Fax Communications" bible, most _modems_ handle this with an AT command - "AT\Bn" (where n is in 100mSec units, from 1 to 9). There are S-register settings for handling the reception of a BREAK, etc.

    However, at the UART level, a BREAK is controlled through bit 6 (BC - Break Control) of the Line Control Register.

    It seems possible to use the EscapeCommFunction(hndl&,%SETBREAK|%CLRBREAK) or SetCommBreak(hndl&)|ClearComBreak(hndl&) to do this, but if you are using PB/DLL's serial communications COMM SET #hComm&, BREAK = 1

    However, I've not tried this - BREAK may be read-only, in which case you'll have to use the afore-mentioned API functions.

    Note that you can retrieve the Operating System handle to an open PB/DLL comm port with FILEATTR(hComm&,2) - you'll need this value to mix the API call with PB/DLL COMM code.

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

    Leave a comment:


  • Adrian C Aitken
    replied
    Hi Tom,
    The break signal *IS* this 'obsolete' signal !! Is it possible to send this via PB 6 ?

    Adrian

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

    Leave a comment:


  • Tom Hanlin
    replied
    Ctrl-Break doesn't correspond to a standard ASCII or ANSI sequence, so you
    would probably need specialized communications software or drivers.

    Depending on your needs, you may be able to send Control-C or another
    key combination instead.

    Then again, there's a communications signal called BREAK which is not
    related to Ctrl-Break (although it's conceivable that some comm software
    interprets the Break key as a command to send a BREAK signal). BREAK is
    a largely obsolete signal once used for purposes such as resetting a
    communications session.

    If this doesn't help, perhaps you could explain what you need in a little
    more detail.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Adrian C Aitken
    started a topic COMM query

    COMM query

    Hi, does anyone know how to send 'Ctrl-Break' down a comms line (it's attached to a Cisco router and using HyperTerm, Ctrl-Break goes into maintenance mode).

    Any help appreciated

    Adrian Aitken

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