VOGONS

Common searches


First post, by pmorath

User metadata
Rank Newbie
Rank
Newbie

I have a model railway which is controlled digitally - meaning that tracks and signals are switched end-to-end according to the time-table, trains start and stop as configured, etc.

The model railway is Märklin with decoders from Trix (Selectrix). The program was developed by me in QBASIC on Windows 3.1 and refined over the years. The connection between the old PC and the model railway was a serial interface (RS232 cable). Now I want to shift from the old PC to my laptop to add some features, e.g. sound.

Attached to my Windows 11 laptop is a USB- to RS232 converter cable, installed on the computer are the DOS-BOX and QBASIC.
The QBASIC program as copied from the old PC is executable inside DOS-BOX - but unfortunately, the RS232-connection doesn't come up.

To locate the area of the issue, I've tested the connectivity between laptop and the model railway control unit with hterm (run in Win11) - in this test the control unit reacted as expected. So the laptop is ok, the USB is ok, the cable as well and also the external device.

Therefore I assume that either the DOS-BOX configuration doesn't support COM-PORT via USB (which I doubt, because many games need serial interfaces as well), or something's wrong with the QBASIC interpreter.

With my old application (ported from Win3.1), the communication at earlier days was successful with statements such as
...
OPEN "com2:9600,n,8,2,cs,ds,rs,cd" FOR RANDOM AS #2
...
PRINT #2, CHR$(128);
...

This should set Bit7 via RS232 (without CR-LF or other control characters) and in effect switch on the model railway central unit.

Does anyone have an idea, if the reason is with DOS-BOX or with QBASIC?
Do I have to change in the set-up of the DOS-BOX? If so, how?
Or am I using wrong QBASIC-commands?

I'm looking forward to your suggestions!

Peter

Reply 2 of 10, by Gmlb256

User metadata
Rank l33t
Rank
l33t

Have you checked the dosbox.conf file to see if the serial interface is configured to use the physical connection? Never had issues with one of these USB to serial adapters (mine has a FTDI controller btw) when playing Hexen in a co-op session.

Nevertheless, I second DosFreak's advice of running it natively if that's possible.

VIA C3 Nehemiah 1.2A @ 1.46 GHz | ASUS P2-99 | 256 MB PC133 SDRAM | GeForce3 Ti 200 64 MB | Voodoo2 12 MB | SBLive! | AWE64 | SBPro2 | GUS

Reply 4 of 10, by pmorath

User metadata
Rank Newbie
Rank
Newbie

Hurray, great, thanks to Gmlb256! The interface is up and running now. Perfect - you saved my day & week 😀

Next thing I'll try is to get my programs compiled by qb64 running as well - because I've seen in the wiki that soundfiles can be embedded there (we'll see how more or less easily that works...). I'll keep you informed.

Reply 5 of 10, by pmorath

User metadata
Rank Newbie
Rank
Newbie

Ok, here's the status after several different approaches:
- the program runs nicely in the DOS-Box with qb11, i.e. interpreter-mode, and the USB-RS232 communication as "COM2" works
- the same program compiled with qb64 results in a "bad file mode" error, and the interface isn't working
- still the test by hterm works well under Windows11, i.e. the manual entry

Are there any properties I need to assign to qb64 or to the compiled program? Or what else could be the reason for the error?

Thanks in advance for your suggestions!

Reply 6 of 10, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

Mabye print is formatted differently in qb64 or doesnt recognize what you are giving it? There should be a debug capability in qb64.

How To Ask Questions The Smart Way
Make your games work offline

Reply 7 of 10, by pmorath

User metadata
Rank Newbie
Rank
Newbie

Thanks for the hint - but the error isn't at the print command. It happens already at the opening attempt, i.e.
Open "com2:9600,n,8,2,cs,ds,rs,cd" For Output As #2

Also trying only
Open "com2:9600,n,8,2" For Output As #2
results in the same error.

Are you aware of another syntax for com-Ports in qb11 versus qb64?

Reply 8 of 10, by pmorath

User metadata
Rank Newbie
Rank
Newbie

I have an idea:
For qb11 I've inserted the following line in the "qb11.conf" (in the subdirectory "_config"):
serial2=directserial realport:COM6
I guess I need to do a similar thing in the config for qb64.
Now the question is: Where is the respective config file for qb64? Is this "setup_win"? or "config" in the subdirectory "internal"? Or anywhere else?

Reply 9 of 10, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie

That is the DOSBox configuration file. That line tells DOSBox to use an emulated COM2 port based on real COM6.
Your problem is you are telling qb64 to use real COM2 which probably doesn't exist - use COM6 instead.

Reply 10 of 10, by pmorath

User metadata
Rank Newbie
Rank
Newbie

Thanks jmarsh!

I've tried, but still confusing results:

- Opening works for Com6 (open "com6:9600,n,8,2..."), i.e. no error is reported at runtime, no matter if I open as random, input or output
- There's indeed a physical connection to the device, because the system behaves differently, if the device is connected (i.e. seemingly ok) versus not connected ("Device unavailable")
- Reading (or likeweise writing) results in "bad file name" or "bad file mode" at different places in the program, depending on the first opening the port (or 2nd after closing)

Where do I find the DOSBox config file? Ie in which of the subdirectories?
What might cause this confusion?

Thanks!!!