From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <44EC9C4C.1040806@domain.hid> Date: Wed, 23 Aug 2006 20:19:56 +0200 From: Wolfgang Grandegger MIME-Version: 1.0 References: <44EC8B62.8020306@domain.hid> <44EC8EAB.8010201@domain.hid> <44EC976E.4000601@domain.hid> In-Reply-To: <44EC976E.4000601@domain.hid> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Xenomai-help] Re: [Socketcan-users] Select on a RTCAN socket List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: xenomai-help Cc: Haukur Hafsteinsson , socketcan-users@domain.hid, Jan Kiszka , Daniel Schnell Wolfgang Grandegger wrote: > Jan Kiszka wrote: >> Hi all, >> >> Wolfgang Grandegger wrote: >>> Hi Daniel, >>> >>> Daniel Schnell wrote: >>>> Hi, >>>> >>>> >>>> >>>> I wanted to use select() on a socket to find out how many messages are >>>> available. I have opened this socket to access the RTCAN sockets under >>>> Xenomai. According to /usr/xenomai/lib/posix.wrappers select is not >>>> "supported" by the realtime kernel. Accordingly it doesn't work. If i >>>> start the according task under SCHED_FIFO, the task simply hangs when >>>> initiating select(), in SCHED_OTHER it is simply returning: bad file >>>> descriptor. >>> select is not supported and cannot be used, indeed. >> And select is tricky to provide under hard-RT constraints. >> >>>> Any ideas ? Is there any other way to find out, how many messages are >>>> waiting ? >>> Select returns the sockets which have data but it does not tell you how >>> many messages are waiting. You could use separate threads to read from >>> sockets. >>> >>> BTW: this mail is off-topic on the socketcan MLs. >> Mmh, do you mean it the other way around? > > Well, I think this is a RTDM/Xenomai related questions and sending it to > xenomai-help is OK. CAN related questions should go to the > socketcan-users maling-list. Am I wrong? > >> Anyway, is there a mechanism of the standard socket API the obtain the >> current incoming queue length? Don't think so actually, but it wouldn't >> be the first time I'm blind. > > Not that I know of. For normal file I/O I remember vague some ioctl() or > fnctl(). Does POSIX define a function for this purpose? Got it! In Linux it can be done with ioctl FIONREAD, which returns the number of bytes that are immediately available to be read on a file descriptor. It could be implemented, if useful. Wolfgang.