![]() |
Error when inputting ASCII text from COM port - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Error when inputting ASCII text from COM port (/showthread.php?tid=2399) Pages:
1
2
|
Error when inputting ASCII text from COM port - MichelleL - 01-23-2024 In my quest to port my QB45 code over to QB64, I am finding things are not 100% portable. Okay, but I'm plugging along trying to learn them. Anyway, my latest is an issue in inputting ASCII text from a COM port. The text would be from 1 to 12 characters followed by the 'enter' key getting pressed. Elsewhere in the program I have used the command 'Open "COM5:9600,N,8,1,RS0,CS0,DS0,CD0" For Random As #1' to handle COM port communications. But for this case, I get a 'Bad File Mode' error for the 'Line Input #1, FILENAME$' command. If I change the 'Random' to 'Input' I then get the 'Input Past End' error; even though I have not typed a single thing in to send over the comm port. I have tried doing a straight Input #1, and a Get #1, still with errors right off the bat without sending any data. I'm at yet another loss as to what I am missing..... DEL1: 'Request file deletion COM5 Close #1 Open "COM5:9600,N,8,1,RS0,CS0,DS0,CD0" For Input As #1 Line Input #1, FILENAME$ KILL1$ = "E:\SERVER\CPM\" + KILLFILE$ Kill KILL1$ Put #1, , EOT$ STATLINE$ = Date$ + " - " + Time$ + " - COM5 File Delete Request" GoSub EVENTSAVE GoSub PRINTSTAT Return RE: Error when inputting ASCII text from COM port - mdijkens - 01-23-2024 read serial like: Code: (Select All)
RE: Error when inputting ASCII text from COM port - bplus - 01-23-2024 can you check that the filename$ is not empty before trying to Input from it? Oh mdijkens beat me! ![]() RE: Error when inputting ASCII text from COM port - MichelleL - 01-23-2024 I will confess, I have never used a SUB or a FUNCTION (MBASIC & GW_BASIC mostly), so I guess I need to noodle out how to put this into one of them, and stick it somewhere... Oh well, the learning never stops. ![]() ![]() RE: Error when inputting ASCII text from COM port - mdijkens - 01-23-2024 (01-23-2024, 05:55 PM)MichelleL Wrote: I will confess, I have never used a SUB or a FUNCTION (MBASIC & GW_BASIC mostly), so I guess I need to noodle out how to put this into one of them, and stick it somewhere... Oh well, the learning never stops.Sorry, this came from a function I've created that also processed the bytes received. You can delete that Static line Use of function: Code: (Select All)
RE: Error when inputting ASCII text from COM port - MichelleL - 01-23-2024 Well, this gets me to File Not Found; without even typing in anything on the computer waiting for me to input the filename so it can be transmitted. I've nulled out the KILLFILE$, and added a couple print statements which don't display anything, as if indicating there is nothing in them. And I have tried both Input and Random for how to open the comm port. I am perplexed..... '------------------------------------------------------------------------------ DEL1: 'Request file deletion COM5 Close #1 Open "COM5:9600,N,8,1,RS0,CS0,DS0,CD0" For Input As #1 KILLFILE$ = "" Dim As String * 1 byte Do While Loc(1) <> 0 Get #1, , byte KILLFILE$ = KILLFILE$ + byte Loop 'Line Input #1, FILENAME$ KILL1$ = "E:\SERVER\CPM\" + KILLFILE$ Kill KILL1$ Put #1, , EOT$ STATLINE$ = Date$ + " - " + Time$ + " - COM5 File Delete Request" GoSub EVENTSAVE GoSub PRINTSTAT Return '------------------------------------------------------------------------------ RE: Error when inputting ASCII text from COM port - bplus - 01-23-2024 what?? Code: (Select All) KILL1$ = "E:\SERVER\CPM\" + KILLFILE$ RE: Error when inputting ASCII text from COM port - mdijkens - 01-23-2024 I think you want to keep receiving bytes until an enter is received. So probably something like Code: (Select All)
Furthermore, try changing the open statement to something like: Code: (Select All)
QB64 is quite picky on serial
RE: Error when inputting ASCII text from COM port - Kernelpanic - 01-23-2024 Quote:@MichelleL - I will confess, I have never used a SUB or a FUNCTION . . .Finally something for fun and play again. ![]() One can also pass a function as an argument to a sub. - You should stop using GoSub these days and replace it with S&F; QuickBasic was already able to do that from 2.0(?) kaufpreis = Purchase price mehrwertSteuer = VAT Endpreis/Gesamtpreis = Final price (total price) Code: (Select All)
RE: Error when inputting ASCII text from COM port - Kernelpanic - 01-23-2024 Oops, I was being too complicated there. ![]() Code: (Select All)
|