• Please review our updated Terms and Rules here

One character at a time!

ziloo

Veteran Member
Joined
Feb 7, 2006
Messages
992
Location
in the basement
Alright programming gurus!

I want to send a character from one PC to another via serial port.
What I need is a program in Quickbasic, that will take care of
sending and receiving one single character at a time. The same
software is sitting on both computers :sigh:.
 
You want to chat or send files?
For sending files you will better use procomm or laplink.

But here are two chatting programs, not written by me, but working good.

http://www.republika.pl/grzesiek21/szereg_oprogramowanie.htm#inne

Site is in Polish, but you shouldn't have any probles with recognising listings, there are two, second use I/O functions built-in QBASIC, so it won't propably run on BasicA or GW-Basic.
 
Did you try searching on the web first? Serial communications from BASIC is all over.
 
Needle in a Haystack

Needle in a Haystack

Whenever one is looking for a needle in a haystack, it is always better to ask
those who have alread been in the barn! ... yee haw ... :biggrin:
 
Good point but are you looking for a program that is already done, or programming examples? And what are you going to do with it? Might help narrow down the corner of the barn to look in.

For programming examples I'd say just go look at some - what you like is a matter of personal preference.
 
Alright programming gurus!
I want to send a character from one PC to another via serial port. What I need is a program in Quickbasic, that will take care of sending and receiving one single character at a time. The same software is sitting on both computers.
There is an example of "Slow Baud Rate for Debugging" in the "Undocumented PC" book. It is in Assembler, but QB can do the same things (hint: you want to set the serial port divisor to give a lower rate of transmission). For vintage systems you could maybe still have a newer UART with FIFO come into play (which could suppress showing the bytes received until the FIFO threshold was reached (in this case it would be best for your program to just disable the FIFOs, if present).

I'll provide some code details momentarily...
 
Alright programming gurus!

I want to send a character from one PC to another via serial port.
What I need is a program in Quickbasic, that will take care of
sending and receiving one single character at a time. The same
software is sitting on both computers :sigh:.

::ears perk::

did you say quickbasic? :D

i reckon i know a bit about that language... there are two real ways to access COM ports in QB. one of which is much easier, so we'll go with that one.

i'll assume you know how to open files for access already. let me know if i'm mistaken here.

you'll want to open a COM port with this command (QB is limited to COM1 and COM2 with this method i believe)

Code:
OPEN "COM1:9600,N,8,1" FOR RANDOM AS #1

obviously, you can change 9600,N,8,1 to whatever you want for port settings.

when you want to read a byte do this:
Code:
tmpbyte$ = SPACE$(1)
GET #1, , tmpbyte$

when you want to write data, do this:
Code:
tmpdataout$ = "omg i am so leet"
PUT #1, , tmpdataout$

you should get the picture. it's fairly easy. there can be a small lag (1 second or so) during GET if there is no waiting data to grab, which is why i don't like using this method but for a chat program or whatever it's not really a problem.

remember to close the open port handle when you're finished like this:
Code:
CLOSE #1

you dont NEED to use #1 as the handle. you can do other numbers. just remember which you use for the PUT and GET commands. to have QB determine the first free file handle, use this command:

Code:
ff = FREEFILE

now the variable ff holds the handle value, and you can replace all "#1" with "ff"

in addition to chatting character by character, you can manage file transfers this way :)


EDIT: if you're having problems trying this, i have no problem loading up QB and actually writing you a sample program for it.
 
There is an example of "Slow Baud Rate for Debugging" in the "Undocumented PC" book. It is in Assembler, but QB can do the same things (hint: you want to set the serial port divisor to give a lower rate of transmission).
One question is that whether QuickBASIC would override your baud rate setting when you OPEN the port, and also prevent you from changing the settings while it is open. The UART in a serial port do happen to deal with "one character at a time", but what time interval will you need? The example has two bits per second (E100h divisor), but shows other divisor rates for things like five bytes per second (divisor of 900h) & up.

For the non-custom programming of the UART, it looks like the DOS interrupt call (INT 14h, Function 0 "Initialize Serial Port") can set the port as low as 110 baud (which is about 11 characters per second). QuickBASIC looks to be more flexible, as my manual (4.5, although older & newer should be similiar here) says you can set the baud rate to what you want. So I guess I come to the position of the other responses to ask what you have tried so far & why it isn't working for you.
 
Last edited:
Thanks a million to all of you champs! Great stuff!
I am going to read up some material (has been a while) and try a few things, and
will get back to you when I get something.
 
it looks like the DOS interrupt call (INT 14h, Function 0 "Initialize Serial Port") can set the port as low as 110 baud (which is about 11 characters per second).

wow.. 110 baud. pfft, screw this cable modem. i'm gonna run a null modem cable to my ISP! it would take well over a second just to transfer a header from a TCP packet lol.
 
Thanks a million to all of you champs! Great stuff!
I am going to read up some material (has been a while) and try a few things, and
will get back to you when I get something.

so what exactly is the program for... i'm assuming you're making a chat proggie?
 
so what exactly is the program for... i'm assuming you're making a chat proggie?

It is a long term project for connecting a PC to a data acquisition system (DAS).
So, I am trying and testing few ideas about serial communication. Later on,
it would be fun to connect several such DAS to a PC in a sort of network
arrangement. But I have a lot of learning to do...
 
It is a long term project for connecting a PC to a data acquisition system (DAS).
So, I am trying and testing few ideas about serial communication. Later on,
it would be fun to connect several such DAS to a PC in a sort of network
arrangement. But I have a lot of learning to do...

thats pretty cool. what kind of PC you going to be running it on? something vintage i guess? 286? XT?

if its all going to be qb, and you need some help i'll be more than glad to help if you need it.
 
...So, I am trying and testing few ideas about serial communication. Later on, it would be fun to connect several such DAS to a PC in a sort of network arrangement. But I have a lot of learning to do...
I highly recommend Jan Axelson's (but I promise I am not a shill for her) "Serial Port Complete" (ISBN 0-9650819-2-3) "Programming and Circuits for RS-232 and RS-485 Links and Networks". Although the code samples are for (Windows-based versions of) Visual Basic they could be ported to QuickBASIC. You can get it from places like Jameco or directly from the author (links from http://www.lvr.com/serport.htm).
 
Back
Top