Use of custom IO functions on non-custom fds

Discussion to talk about software related topics only.
Post Reply
addonray
Posts: 19
Joined: Thu Sep 03, 2015 10:46 am

Use of custom IO functions on non-custom fds

Post by addonray »

Hi,

Is it safe to use functions like SetHaveError() on a "regular" fd, to fire Select()? Such as with a TCP socket, where Select blocks forever in a high priority task, and a lower priority task is checking enet0.EtherLink() for LAN cable integrity, finds it bad, and calls SetHaveError() for that socket. I've only seen the docs for this refer to SetHaveError in terms of custom fds.

I would also like to use it to "force" serial port errors in Select from a lower priority task (without having the port encapsulated in a custom fd). The low priority task tests incoming CTS to know the host is connected. If we lose CTS, I'd like Select to fire with an error.

Lastly, I'd like to buffer some data to be sent via a standard TCP fd, from a lower priority task, then wake up Select with a SetWriteAvail() to then have the Select task code write the data out to the LAN. The idea is for the Select task to assemble a preamble, manage an application level sequence number, etc. to command packets coming from the lower priority task. Is that how it's supposed to work with the write fds Select set?

Thanks!

Ray
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: Use of custom IO functions on non-custom fds

Post by pbreed »

Yes you can set have error.
Not how it was designed to work, but it will...

A cleaner version would be to add your own custom FD and add that to the select and notiufy via that.
(IE the key to select is you can wait on multiple FD's)
Post Reply