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

Thread Starter

MMcLaren

Joined Feb 14, 2010
861
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
 

someonesdad

Joined Jul 7, 2009
1,583
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).
 

retched

Joined Dec 5, 2009
5,207
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.
 

Thread Starter

MMcLaren

Joined Feb 14, 2010
861
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).
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
 

BMorse

Joined Sep 26, 2009
2,675
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.

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
 

Thread Starter

MMcLaren

Joined Feb 14, 2010
861
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.
Thanks RM. I'm lookin' at kBasic documentation now.

Kind regards, Mike
 

BMorse

Joined Sep 26, 2009
2,675
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

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
 

BMorse

Joined Sep 26, 2009
2,675
My first computer was a VIC20, I have been around for while and seen things come and go ;)

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
 

someonesdad

Joined Jul 7, 2009
1,583
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.
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).

Rich (BB code):
def ScanInterfaces(bus_name):
    ''''Find what instruments are connected.  The dictionary returned
    contains the devices found keyed by the string that identifies the
    instrument on the bus.

    bus_name must be "gpib" or "usb".
    '''#
    d = {}
    for instrument in visa.get_instruments_list():
        if instrument.lower().find(bus_name.lower()) == 0:
            inst = visa.Instrument(instrument, term_chars = "")
            response = inst.ask("*IDN?")
            d[instrument] = response
    return d

def ScanSerial():
    print "\nSerial instruments:"
    ports = []
    for i in range(256):
        try:
            s = serial.Serial(i)
            ports.append(i)
            s.close()
        except serial.SerialException:
            pass
    if ports:
        print "  Active ports: ", [i+1 for i in ports]
    for port in ports:
        for br in (38400, 19200, 9600, 4800, 2400, 1200):
            try:
                se = serial.Serial(port, baudrate=br, timeout=0.5)
                se.write("*IDN?\n")
                s = se.readline().strip()
                se.close()
                del se
                if s:
                    print "  COM%d" % (port + 1), br, s
                    break
            except serial.SerialException:
                if se:
                    se.close()
                    del se
ScanSerial()
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.
 

n9352527

Joined Oct 14, 2005
1,198
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#.
 

n9352527

Joined Oct 14, 2005
1,198
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:

BMorse

Joined Sep 26, 2009
2,675
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.

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
 
Top