Free PC BASIC or C that can toggle RTS, DTR, and read CTS?

Discussion in 'Programmer's Corner' started by MMcLaren, May 5, 2010.

  1. MMcLaren

    Thread Starter Well-Known Member

    Feb 14, 2010
    759
    116
    Can anyone recommend a free PC BASIC or C with the capability to toggle the serial port RTS and DTR outputs and read the CTS input?

    TIA. Mike McLaren, K8LH
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
  3. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234
    What OS are you running?? If you are running Linux or Windows, check this out >> http://www.qbasic.com/



    B. Morse
     
  4. someonesdad

    Senior Member

    Jul 7, 2009
    1,585
    141
    Consider taking a look at using pySerial in a python program -- it may do what you want -- I control a variety of instruments using python (serial, USB, and GPIB instruments). If you haven't used python, consider giving it a try, as it's a powerful and free tool. An experienced C programmer can be producing useful python programs in an hour or so. And your knowledge and code will be portable amongst different OSes (excluding, obviously, platform-specific code).
     
  5. MMcLaren

    Thread Starter Well-Known Member

    Feb 14, 2010
    759
    116
    I've got XP-SP3 and Vista Home on laptops.

    I will check out qbasic. Thank you.

    Regards, Mike
     
  6. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    KBasic is a full flavor BASIC. It can handle all you want. It is QBasic / VisualBASIC / and Java all rolled into one.

    http://www.kbasic.com/

    You will be quite happy. It is FULLY syntax compatible with VB6, VBA and QBasic.

    Check it out.

    And if you ever decide to take Ubuntu or any linux for a try, check my blog for setting it up in linux.
     
    kingdano likes this.
  7. MMcLaren

    Thread Starter Well-Known Member

    Feb 14, 2010
    759
    116
    Thank you.

    I downloaded and installed Python. There's sooo much material there. After a couple hours reading and going through simple tutorials I still haven't quite figured out how you get past "interactive" mode and would write a program (LOL). I will keep plugging away at it.

    Regards, Mike
     
  8. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    I will have to check that out.... I might be able to dig up some of my old QBasic programs and play Kong!!

    B. Morse
     
  9. MMcLaren

    Thread Starter Well-Known Member

    Feb 14, 2010
    759
    116
    Thanks RM. I'm lookin' at kBasic documentation now.

    Kind regards, Mike
     
  10. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Ok bmorse, now you have to send me KONG.

    ...trying to follow your footsteps is tiring. ;)
     
  11. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234
    If I manage to dig it up I will post it on here....

    B. Morse
     
  12. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I prefer the MAME simulator. Then I can play all my favorite arcade games from the good old days. Like Pacman, Donkey Kong, Duck Hunt, and others
     
  13. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    MAME consoles are fine (I have one that emulates Super NES, PS1 and PS2, and others), but this Kong game was an old IBM game that people use to play before windows was even around.... way back in those BBS days.....


    B. Morse
     
  14. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    My first computer was a VIC20, I have been around for while and seen things come and go ;)
     
  15. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    I still have my Vic20 and my Commodore 64 :D! I still also have my Tandy1000, and 2 full Atari Systems (Although my woman sold all my game cartridges at a garage sale years ago!:mad:)

    B. Morse
     
  16. someonesdad

    Senior Member

    Jul 7, 2009
    1,585
    141
    Mike: keep plugging away and it will eventually make sense. I came across python 12 or 13 years ago and taught myself from the tutorial document that comes with python.

    The basics of a non-interactive program are as follows:

    1. Write a program script. Call it e.g. my_program.
    2. Run it at a command line with python: python my_program.

    You'll need to have the python install directory in your PATH to do this. If you eventually start writing your own library code, you'll also need to set up PYTHONPATH appropriately. For example, mine is

    PYTHONPATH='.;d:/p/pylib;d:/utilities/g'

    which shows <hangs his head in shame> that I'm running on a Windows machine. :p

    If you're using a windowing environment (MS Windows, X Windows, etc.) there are ways to get it to execute there too by e.g. double-clicking. But I suggest starting with the command line scripts.

    Here's an example script I use to scan the serial ports to find connected instruments. It also shows the function used to scan the USB and GPIB buses -- they're easier to deal with than serial ports using the pyVisa library. I would have used pyVisa for the serial ports too, but for some reason it doesn't work with my hardware (although a friend uses it just fine for serial ports on his machine).

    Code ( (Unknown Language)):
    1.  
    2. def ScanInterfaces(bus_name):
    3.     ''''Find what instruments are connected.  The dictionary returned
    4.     contains the devices found keyed by the string that identifies the
    5.     instrument on the bus.
    6.  
    7.     bus_name must be "gpib" or "usb".
    8.     '''#
    9.     d = {}
    10.     for instrument in visa.get_instruments_list():
    11.         if instrument.lower().find(bus_name.lower()) == 0:
    12.             inst = visa.Instrument(instrument, term_chars = "")
    13.             response = inst.ask("*IDN?")
    14.             d[instrument] = response
    15.     return d
    16.  
    17. def ScanSerial():
    18.     print "\nSerial instruments:"
    19.     ports = []
    20.     for i in range(256):
    21.         try:
    22.             s = serial.Serial(i)
    23.             ports.append(i)
    24.             s.close()
    25.         except serial.SerialException:
    26.             pass
    27.     if ports:
    28.         print "  Active ports: ", [i+1 for i in ports]
    29.     for port in ports:
    30.         for br in (38400, 19200, 9600, 4800, 2400, 1200):
    31.             try:
    32.                 se = serial.Serial(port, baudrate=br, timeout=0.5)
    33.                 se.write("*IDN?\n")
    34.                 s = se.readline().strip()
    35.                 se.close()
    36.                 del se
    37.                 if s:
    38.                     print "  COM%d" % (port + 1), br, s
    39.                     break
    40.             except serial.SerialException:
    41.                 if se:
    42.                     se.close()
    43.                     del se
    44. ScanSerial()
    45.  
    46.  
    This code doesn't have many comments for the beginner; after you learn the syntax and get comfortable with using objects, code like this is mostly self-documenting.
     
  17. n9352527

    AAC Fanatic!

    Oct 14, 2005
    1,198
    4
    You can use direct IO driver, such as Inpout32, PortTalk or UserPort. Then you can access the port directly using inp/outp, like the old days ;)

    You can use these drivers with any programming language that supports access to DLL functions, such as VB, C, C#.
     
  18. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    That is why the op is asking for a FREE basic program.....:rolleyes:

    B. Morse
     
  19. n9352527

    AAC Fanatic!

    Oct 14, 2005
    1,198
    4
    The problem is not programming language, Windows 2K/XP/Vista/7 prohibits direct access to any ports. Running QBASIC or any other free programming language (such as GCC, LCC or MinGW) does not change the fact that direct IO access is not allowed. Thus making it difficult to control the port hardware, therefore the RTS or CTS lines individually.

    These direct access IO drivers allow that. You can use them with any programming language that you have or want, as long as it supports access to DLL. VS 2008 Express, VB, VC, VC# are free from MS, there are also GCC, LCC, MinGW. Take your choice.
     
    Last edited: May 7, 2010
  20. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    That is already a known fact about windows OS's, the ops question is not how to access the ports, but what FREE PROGRAM can he use to do it with, DLL's and OCX's are fine to use, but you still need a programming language to do it in no matter if it was free or not, THAT is the original question here.

    B. Morse
     
Loading...