Announcement

Collapse
No announcement yet.

Non-standard baud rates

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

  • Scott Turchin
    replied
    Wow that brings back some memories!
    Since my app was configurable from INI files this is how I did it:
    Obviously BaudRate$ is set as you please, and the N,8,1 part you will have to set according, likely what, P,8,0? I'm not sure - been a while since I messed with synchronous stuff.....

    This app listened for a RING, below I will post some code for ya as well in case you want it.


    Code:
    If IRQ=3 Or IRQ=4 Then
            COMOPEN$="COM"+Left$(Comport$,1)+":"+Left$(BaudRate$,5)+",N,8,1"
    Else
            COMOPEN$="COM"+Left$(Comport$,1)+":"+Left$(BaudRate$,5)+",N,8,1,IR"+LTrim$(Str$(IRQ,1))
    End If   'The else sets for funky irq's...      
    
    hCom = Freefile
    Open ComOpen$ as #hCom
    
    That was the basics.
    '
    '
    '
    
    Function Carrier( ByVal Port% ) PUBLIC
      If Port% < 1 Then
        Carrier = 0
        Exit Function
      End If
      Local Status
    
      ! push DS; save DS for PowerBASIC
    
      ! mov BX, Port%; put port number in BX
      ! shl BX, 1; multiply it times 2
      ! add BX, &H3FE; add 3FEh to it
      ! xor DX, DX; access bios data area
      ! mov DS, DX; put segment into DS
      ! mov DX, DS: [BX]; get port address
      ! add DX, 6; status register at offset 6
      ! in AL, DX; get status byte into AX
      ! mov CL, 7; we want bit 8
      ! shr AX, CL; shift it into place
      ! and AX, 1; isolate first bit
      ! neg AX; convert to 0 or - 1
      ! mov status, AX; put into temp variable
    
      ! pop DS; restore DS for PowerBASIC
    
      Carrier = Status
    
    End Function
    '------------------------------------------------------------------------------
    Function CtsStatus( ByVal Port% ) PUBLIC
    
      Local Status
    
      ! push DS; save DS for PowerBASIC
    
      ! mov BX, Port%; put port number in BX
      ! shl BX, 1; multiply it times 2
      ! add BX, &H3FE; add 3FEh to it
      ! xor DX, DX; access bios data area
      ! mov DS, DX; put segment into DS
      ! mov DX, DS: [BX]; get port address
    
      ! add DX, 6; status register at offset 6
      ! in AL, DX; get status byte into AX
      ! mov CL, 4; we want bit 5
      ! shr AX, CL; shift it into place
      ! and AX, 1; isolate first bit
      ! neg AX; convert to 0 or - 1
      ! mov status, AX; put into temp variable
    
      ! pop DS; restore DS for PowerBASIC
    
      CtsStatus = Status
    
    End Function
    
    '------------------------------------------------------------------------------
    Function DtrStatus( ByVal Port% ) PUBLIC
      If Port% < 1 Then
        DtrStatus = 0
        Exit Function
      End If
      Local Status
    
      ! push DS; save DS for PowerBASIC
    
      ! mov BX, Port%; put port number in BX
      ! shl BX, 1; multiply it times 2
      ! add BX, &H3FE; add 3FEh to it
      ! xor DX, DX; access bios data area
      ! mov DS, DX; put segment into DS
      ! mov DX, DS: [BX]; get port address
    
      ! add DX, 4; status register at offset 4
      ! in AL, DX; get status byte into AX
      ! and AX, 1; isolate first bit
      ! neg AX; convert to 0 or - 1
      ! mov status, AX; put into temp variable
    
      ! pop DS; restore DS for PowerBASIC
    
      DtrStatus = Status
    
    End Function
    '------------------------------------------------------------------------------
    Function Ring( ByVal Port% ) PUBLIC
    
      Local Status
      ! push DS; save DS for PowerBASIC
      ! mov BX, Port%; put port number in BX
      ! shl BX, 1; multiply it times 2
      ! add BX, &H3FE; add 3FEh to it
      ! xor DX, DX; access bios data area
      ! mov DS, DX; put segment into DS
      ! mov DX, DS: [BX]; get port address
      ! add DX, 6; status register at offset 6
      ! in AL, DX; get status byte into AX
      ! mov CL, 6; we want bit 7
      ! shr AX, CL; shift it into place
      ! and AX, 1; isolate first bit
      ! neg AX; convert to 0 or - 1
      ! mov status, AX; put into temp variable
      ! pop DS; restore DS for PowerBASIC
    
      Function = Status
    
    End Function

    ------------------
    Scott Turchin
    MCSE, MCP+I
    Computer Creations Software
    http://www.tngbbs.com/ccs

    Leave a comment:


  • Donald Darden
    replied
    Sorry, that was a split-off with the new PB/CC command syntax.
    You would still use OPEN "COM1:yadda,yadda,yadda" in PB/DOS.
    All you need to do is figure out what to put in for the yaddas.

    This is an extract from the PB/DOS Help Files, under OPEN:

    The keyboard, screen, printers, and communications ports may be opene
    as files using filenames "KYBD:", "SCRN:", "CONS:", "LPT1:", "LPT2:",
    "LPT3:", "COM1:", "COM2:", "COM3:", and "COM4:". "KYBD:" and "CONS:"
    use DOS for all I/O, allowing both input and output to be redirected.
    "SCRN:" writes to the screen memory directly, preventing redirection.
    Access and Lock network modes may be specified when using DOS 3.0 or
    later. 'access' is one of READ, WRITE, or READ WRITE. lock is either
    SHARED, LOCK READ, LOCK WRITE, or LOCK READ WRITE. Specifying ACCESS
    READ means that only subsequent read operations will be allowed on th
    file; attempting a write operation will cause an error. ACCESS WRITE
    allows only write operations, while ACCESS READ WRITE allows both. LO
    WRITE means that this file cannot be written to by other users while
    have it open; an attempt to do so will generate an error for the othe
    user. The file can still be read by another user, however.

    Note that I mentioned that PB does cover serial communications in
    some debth, but more so with PB/CC and PB/Win. Back when PB/DOS
    had its heyday, modem communications was a lot more prevalent
    than today, and you usually were expected to just refer to the
    modem handbook as to how to set up the COM port, which represented
    both the UART and the Modem proper (The UART was the serial port
    circuitry, and the Modem was the communications device for
    communicating over standard phone lines. For some installations,
    the functions were consolidated into one).

    Note that the UART and the Modem speeds do not have to correspond
    to each other. The near and distant modems connect and exchange
    information using their own protocols, compression and decompression
    algorythms. and follow standards such as v.42, V.80, V.90, and
    V.92. It is a frequent habit to set the UART speed to a higher
    rate, such as 115,000 for a 56 KB connection, on the expectation
    that the PC will service the connection more frequently and reduce
    the likelihood of a communications error.

    Here are some links that may be of some value: http://www.uktsupport.co.uk/reference/modem.htm http://www.computerhope.com/atcom.htm http://www.sixnetio.com/htmlhelps/vtmodem/5a78555.htm http://www.sixnetio.com/htmlhelps/vtmodem/5a6804f.htm http://zone.ni.com/devzone/conceptd....6F6A007F154C#6 http://news.managingautomation.com/fullstory/452471 http://www.docklight.de/manual/index...ctsettings.htm http://www.hallogram.com/commdrv/libfeat.html http://www.sinnovations.com/htdocs/s...2_analyzer.htm http://www.commtech-fastcom.com/Data...324PCI335.html
    GetCommModemStatus http://www.geocities.com/terminalplus/ http://www.amplicon.co.uk/dr-prod3.c...upId/10795.htm http://www.digibuy.com/cgi-bin/produ...l?109311792044

    Because modem developers often pursued the path of trying to
    provide advance features for their modems that exceeded those
    of their rivals, all modems tended to follow the Hayes AT
    command set and lower register designations, but went in different
    directions beyond that point. So for advance features, you
    usually had to refer to specific documentation for a given
    model or family of modems. Note that modems are usually
    programmed or modified as to their settings after the COM port
    has been opened, using special ASCII command strings.

    If you are trying to connect directly to a COM port without the
    involvement of a modem, you are limited to what commands can be
    recognized by the UART and communications program, and the fact
    that the UART is controlled through certain I/O registers that
    correspond to addresses associated with that COM port. These
    are easily modified in DOS, but 32-bit Windows does not want to
    give the user ready access to these locations.

    There are two approaches to this problem: The first is to look
    for software that circumvents Windows, opening the COM ports so
    that you can manipulate them. The second way is to acquire a
    serial interface card that is specifically designed to work in
    Windows and which gives you added control, including nonstandard
    baud rate settings. The links above include references to both
    approaches. I personally have liked the COMM-DRV libraries,
    which I first encountered through the 3rd party offerings on
    this web site.

    I should have said that there is a third way, which is the
    Windows way. Now I know that PB/DOS developers are not really
    into Windows API calls, but there is a knowledge section on
    working with COMM devices at this location:
    http://msdn.microsoft.com/library/de..._functions.asp

    The idea of course is that you can either go this course yourself,
    or you can get a comm library (DLL) that handles the comm port
    settings under Windows for you. In addition, there are products
    that offer a combined hardware/software solution.



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

    Leave a comment:


  • William Haynes
    replied
    Donald, thank you for the post. I can not find the "COMM OPEN" in either
    of my PowerBasic books (User Guide or Reference Guide) can you
    point me to info on the command? It sounds like it's just what
    I'm looking for.

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

    Leave a comment:


  • Donald Darden
    replied
    Dividing 115,000 by some integer to derive a baud rate is the
    method required. The rate of 8214 (115,000 / 14) is as close as
    you can get, and will likely work. You need to use the COMM OPEN
    statement, during which you can send a number of optional
    parameters to the UART, including baud rate and control signal
    settings. PB Help files go to some length to try and steer you
    in the right direction, but it does not hurt to consult another
    source of RS-232, Serial, or Modem communications. Note that not
    all serial connections or cables are alike, and this means that
    you may have experiement a bit with enabling or disabling some
    of the signales to get it to work right.

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

    Leave a comment:


  • Aldo Cavini
    replied
    William, just open the COMx with the standard PBDOS statement, then OUT the corret divisor value to the UART. Of course you need not to be running on a NT platform, since OUTs are prohibited.

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

    Leave a comment:


  • Paul Dixon
    replied
    William,
    I'd have thought you'd just need to open the port using "OPEN COM.." choosing parameters to get it as close as you can to the desired rate.
    Then write the values you really need directly into the UART registers using INP and OUT. It sounds like you know how to use the UART on a PC clone so it's exactly the same as PB runs that same UART chip in a PC clone.

    Paul.




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

    Leave a comment:


  • Mel Bishop
    replied
    The only thing I can think of is trying to set the baud rate and
    opening the port using ASM. Non-standard baud rates, to the best
    of my knowledge is not possible using standard PB function(s).


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

    Leave a comment:


  • William Haynes
    started a topic Non-standard baud rates

    Non-standard baud rates

    Does anyone know how to set non-standard baud rates. I need a baud
    rate of 8192. The low level logical format of GM's 8192 baud ALDL
    data stream is a simple async data stream with 8 data bits, no
    parity bit, and 1 stop bit. This is the type of data stream that
    most UARTs (Universal Async Receiver Transmitter) can handle. The
    PC (IBM clone) has a UART that can be set close to 8192 baud
    (actually 8226.6 baud, using a divisor of 14 with the 115,200
    Hz UART clock - giving a 0.42 fast clock, a negligible difference).
    Does anyone have any experience configuring baud rates other then
    the standard COM rates using PowerBasic for DOS?

    Thank you all for your help. I am using XP and still struggling to
    make this work. It seems like a simple:
    OPEN "COM1: 115200,D=14,N,8,1" AS #1 LEN=1 where the 14 is the divisor
    or maybe something like: COM(1) /14 to set the divisor needed would be really usefull.
    would be a big help.

    [This message has been edited by William Haynes (edited September 22, 2005).]
Working...
X