Jump to content
IGNORED

Timeout waiting for INPUT in BASIC?


Recommended Posts

Hi everyone,

 

I was wondering if there is some kind of timeout mechanism when using INPUT with an external device in BASIC?

The problem I'm facing is that INPUT seems to wait for something like an EOL/CR/LF to return control to the program. In my scenario, where I receive data from a serial interface using the R: handler, there may not be an end-of-line character for a long time if the other side does not type anything. If that is the case for let's say longer than 10 seconds, I want my program to continue processing. So is there a way to prevent waiting - at worst - forever?

 

In the beginning, I tried using GET #1,A, but that was quite a lot slower than INPUT. Plus, I also forgot the memory address that tells me how may bytes are waiting in the IOCB buffer and couldn't find the information after quite some searching. Could anyone give me a pointer? And maybe tell me why GET is so much slower than INPUT and if there is a possibility to speed GET up?

 

Thanks a lot in advance,

 

F.

Link to comment
Share on other sites

Ok, part of the answer to my problem can be found on page 8/9 of the technical manual of the Atari 850: BREAK key is disabled for concurrent mode I/O, and it states that there is no way to make INPUT end after a timeout. GET in combination with STATUS is then recommended and the memory location I was looking for is 747.

The question remains if there are ways (accessible to BASIC) to speed things up with GET?

Link to comment
Share on other sites

For devices other than K: E: and S: using INPUT and even the record oriented XIO commands in Basic can give undesired results.

Often the incoming data isn't record oriented with the CR character which will be problematic with Basic handling.

 

You're probably way better off using an assembly routine called by USR which passes IOCB, command and buffer address & length.

 

Link to comment
Share on other sites

There is no way to timeout INPUT. What you can do is to query KeyCodeShadow, and if this is 255, continue operation of the program. If it is set, get the next keypress through GET. You would then need to implement some elementary editing functions (such as backspace) yourself.

For the serial port, you can find out how much data has been buffered up and can be retrieved. For that, issue a status, and then read the number of buffered bytes from $2eb and $2ec. If this is zero, there is nothing to read from R: Otherwise, you can retrieve the bytes without blocking.

This should give you about an idea how to run the input loop.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...