Shop OBEX P1 Docs P2 Docs Learn Events
FlexProp Console Port Functions — Parallax Forums

FlexProp Console Port Functions

Hi @ersmith,

I just started working with FlexProp and have some questions lined up.

The first one deals with the serial library for I/O access via the Prop2 console port (P62 & P63).

I'm working on a C program that will communicate with a GPS receiver and WiFi radio. The program presents various Menus to the operator. One shows WiFi radio status, another shows the raw incoming GPS messages, another shows raw Satellite messages and status, another shows GPS navigation and position information, another shows diagnostic info, etc.

The desired Menu screen is selected from the Main Menu by hitting a numeric key (1 thru 9). The screen is then cleared and the desired information displayed.

I could use getchar() to grab the numeric key, but this also requires a carriage return which I want to avoid.

What I really need is something like getkey() that scans for an incoming character but doesn't require the carriage return.

Does FlexProp have a getkey() function (or something similar) available? I can't seem to find it anywhere.

If not, does BASIC have an INKEY$ function available? If so, maybe I can have mixed code where BASIC scans for incoming characters and then passes them to the C code via shared or global memory or something...

Comments

  • JRoarkJRoark Posts: 1,215
    edited 2021-07-09 20:25

    Take a peek at the _rxraw() function in the C library. You can call it from BASIC. I’ll post an example for you when I get home tonight, but basically (from memory):

    Dim inchar as byte
    Do
       inchar = _rxraw()
       If inchar > -1 then
          Print inchar 
       End if
    Loop
    

    Edit: from an earlier thread:
    ————-
    int _rxraw(int n=0)

    Receives a character on the default serial port. n is a timeout in milliseconds. If
    the timeout elapses with no character received, _rxraw returns -1, otherwise it
    returns the received character. The default timeout (0) signifies "forever"; that
    is, if n is 0 the _rxraw function will wait as long as necessary until a character arrives
    ————
    See GENERAL.PDF doc in the FlexProp dcs

  • @JRoark said:
    Take a peek at the _rxraw() function in the C library. You can call it from BASIC. I’ll post an example for you when I get home tonight, but basically (from memory):

    Awesome, that did the trick! Many thanks!

  • There's some documentation on serial port control functions in the "general compiler features" document (general.pdf). I'll put a pointer to that in the C document as well.

Sign In or Register to comment.