Kurt, Wolfgang,
thank you for pointing on that issue.
Well, I guess for the purposes of the test the following simple
construction
is actually enough:
while( write(s, &tx_frames[send_pos], sizeof(*tx_frames)) !=
sizeof(*tx_frames) )
{
perror("write");
return 1;
}
If everything is fine, no errors usually occur on this place because of
synchronous operation of canecho_gen and canecho_dut. (txqueuelen of CAN
interface shall be bigger than CAN_MSG_COUNT, I have used txqueuelen of
1000 both on DUT and test PC).
Wolfgang, my error on handling the "write" does not deny the fact, that
the
MSCAN driver works proper now 8)
Regards,
Vladislav
-----Original Message-----
From: Wolfgang Grandegger [mailto:[email protected]]
Sent: Monday, September 21, 2009 11:11 AM
To: Kurt Van Dijck
Cc: Gribov, Vladislav; [email protected]
Subject: Re: [PATCH] mscan: fix TX message handling to ensure proper
message ordering
Kurt Van Dijck wrote:
> On Mon, Sep 21, 2009 at 10:30:07AM +0200, [email protected] wrote:
>> Hello Wolfgang,
>>
>> I have tested SW again and cannot reproduce error situation I had
>> yesterday.
>> Everything turns out to be OK. Was it Sunday effect? I have no
idea...
>> The write function issue you have mentioned is fixed (see attached).
> I looked at the code.
>
> while( (nbytes=write(s, &tx_frames[send_pos],
sizeof(*tx_frames))) !=
> sizeof(*tx_frames) )
> {
> if(nbytes!=EAGAIN)
> {
> perror("write");
> return 1;
> }
> }
>
> I don't know the exact purpose of the test.
> This loops asks for sunday effects, isn't it?
>
> nbytes would return -1, not EAGAIN!
> if ((nbytes < 0)&&(EAGAIN == errno))
With proper error handling it should look like:
if (nbytes < 0) {
if (errno == ENOBUFS)
continue;
perror("write failed");
} else {
fprintf(stderr, "write returned bogus %d\n", nbytes);
}
return 1;
> is what I think you meant
Ah, oh, sure, missed that :-(. Thanks for pointing that out.
> my preference:
>
> int ret;
> struct pollfd pollfd;
>
> pollfd.fd = s;
> pollfd.events = POLLOUT;
> while ((ret = poll(&pollfd, 1, -1)) < 0) {
> if (EAGAIN == errno) {
> perror("write");
> return 1;
> }
> }
> nbytes = write(s, ....)
> // nbytes with anything other than sizeof(*tx_frames) is a serious
> // poll issue
>> Regards,
>> Vladislav
As Marc pointed out, poll/select will block in case of ENOBUFS.
Wolfgang.
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core