Re: AX25 programming

From: Richard Stearn (terhi.victor@logonet.com)
Date: Thu Jul 19 2001 - 23:51:52 EEST

  • Next message: John R. Ackermann: "Slightly OT: accessing I/O ports under Linux?"

    > Ok, how do I know when to issue a read? It seems like if I issue reads
    > constantly this will bog down the system. So far I envision::
    > while (1) {
    > read(0,very_large_buf_,sizeof(very_large_buf));
    > /* Do work on buffer */
    > }

    There are a number of ways to handle this, the two I use regularly are:
            1) have two processes on out-going, one incoming. Disadvantage is
                    having to setup inter-proccess comms if required.
            2) use "select" to detect incoming data on your connections from the
                    world outside your process.

    Issuing a blocking read does not "bog the system down" it actually releases
    the CPU to other processes until there is data available in the file.

    Select on the other hand can be used to poll the files for available data
    (time out = 0) or to wait indefinately ( timeout = NULL ).
    What it does offer is the ability to return and indicate which file has data
    available, invaluable when wanting to listen on more than one file at a time.

    > Also, if I read past where the fragment ends it seems to be that I will
    > get garbage. How do I know where the fragment ended?

    "read" returns the number of bytes read so you know how much of your
    buffer is valid data.

    -- 
    Regards
    	Richard
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Amateur radio callsign: G1SOG         Home BBS: G1SOG@GB7GLO.#46.GBR.EU
                    Amprnet co-ordinator for Wiltshire
    My opinions are mine, all mine. None to spare for unopinionated masses.
    This message comes from a WinTel free zone.   CPU = Cyrix,  OS = Linux.
    Unix is user friendly.        Just rather selective about it's friends.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -
    To unsubscribe from this list: send the line "unsubscribe linux-hams" in
    the body of a message to hegj@kabelnet.net
    



    This archive was generated by hypermail 2b30 : Fri Jul 20 2001 - 05:56:50 EEST