Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - joe_cool61

Pages: [1]
1
QB64 Discussion / Re: need help with OPEN COM
« on: February 27, 2019, 05:20:15 pm »
Well, I've continued trying but have come to the conclusion that QB64 just doesn't work the way I need it to. Having OPEN COM for RANDOM work only in BIN mode is a hindrance.

Another weird thing: When trying Axeman's suggestion in the post immediately above, I get a "Bad file name" error when it tries to OPEN COM2 for INPUT after having closed it for OUTPUT. Why isn't #12 (or #-whatever) a satisfactory file name? (Actually I use COM4 rather than COM2 but I don't think this should matter.)

Even if I could open COM4 for INPUT as well as OUTPUT, it would become a pain for all the flip-flopping the COM port would have to do when writing to and reading from the Fluke test instrument.

Granted, my lack of skill as a programmer may be at the root of all this. However, while scouring the Web I came across Liberty BASIC and downloaded it. It does support OPEN COM for RANDOM and now I am able to write to and read from the instrument just as I could with QB 4.5 . So I'm finally on the road to accomplishing my task.

Thanks to everyone for all the suggestions.


2
QB64 Discussion / Re: need help with OPEN COM
« on: February 12, 2019, 11:41:05 am »
Thanks for all the input, everyone. It will take a few days before I can get back to work on this matter, as I'm trying to squeeze it in among my other work duties. I'll post the results here.

Axeman - Thanks for pointing out the #12 vs. #11 discrepancy; that was just a typo as I was composing the original post.

Pete & Cobalt - I promise not to lob any ticking pineapples or other tropical fruit on this forum! :-)

-Joe

3
QB64 Discussion / need help with OPEN COM
« on: February 11, 2019, 12:58:35 pm »
Hi. Am new to the forum. I've been a QB 4.5 user for many years, using it to control electronic lab instruments via RS-232 to make voltage measurements and log test data. I was very pleased to find QB64 as a modern alternative that can run in Windows 10. I wish to ask for the forum's help to get my test system up and running again.

My original QB4.5 program used OPEN FOR RANDOM for communicating with a digital multimeter. It sends a command to the meter, reads and discards the echo that the meter sends back, then reads the prompt that the meter sends back. See following snippet of the original QB 4.5 program:

MeterSetup:
OPEN "COM2:1200,N,8,,CS,DS,CD" FOR RANDOM AS #11 'open path to Fluke 45
Cmd$ = "REMS;VDC;RANGE 3;RATE M;FORMAT 1"
GOSUB ProgramFluke

ProgramFluke:
PRINT #11, Cmd$
LINE INPUT #11, Result$    'clears the echo response from meter
Prompt$ = INPUT$(5, #11)   'reads the prompt returned by the meter
RETURN


Running this same program in QB64 causes error "Bad file mode" at PRINT #11, Cmd$ I figured this is because of the description of OPEN COM from the QB64 Wiki: "Currently, QB64 only supports OPEN FOR RANDOM access using the GET/PUT commands in BIN mode." I don't know what BIN mode is, so I tried changing the mode from RANDOM to OUTPUT. However, I realize that it won't be able to read anything from the meter in OUTPUT mode, so I CLOSE the path after sending Cmd$ and try to re-open it in INPUT mode as follows:

MeterSetup:
OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR OUTPUT AS #11 'open path to Fluke 45
Cmd$ = "REMS;VDC;RANGE 3;RATE M;FORMAT 1"
GOSUB ProgramFluke
CLOSE #11
OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR INPUT AS #12 'open path to Fluke 45
LINE INPUT #11, Result$    'clears the echo response from meter
Prompt$ = INPUT$(5, #11)   'reads the prompt returned by the meter

ProgramFluke:
PRINT #11, Cmd$
RETURN

This succeeds in sending the Cmd$ to the meter which gets set to the desired settings, but I get error message "Bad file name" for the OPEN FOR INPUT statement. Why? The COM port had worked fine as OUTPUT just moments earlier. How can I now read what the meter is sending back?

I'd appreciate any help you can offer. Thanks!


Pages: [1]