Remember me

Lost Password?

Register now!


Who's Online
41 user(s) are online (21 user(s) are browsing Forums)

Members: 1
Guests: 40

kas1e, more...

Support us!


how to work properly with device when you need query every 5 seconds
Home away from home
2007/9/11 12:31
From Russia
Posts: 7022
The question comes up after finding that when you need one time in a 5-second query something from a serial device, then if you open-close device for every query, then you have 100% CPU load hit on that time. I.e there is init code:

BOOL initX5000serial(struct DockyData *dd)
int8 err 0;

dd->port IExec->AllocSysObject(ASOT_PORTNULL);
dd->req IExec->AllocSysObjectTags(ASOT_IOREQUESTASOIOR_Size,sizeof(struct IOExtSer),
IExec->OpenDevice("serial.device"1, (struct IORequest*)dd->req0) != -1)
// Set parameters to address MCU 
dd->req->IOSer.io_Command SDCMD_SETPARAMS;
dd->req->io_Baud      38400// 38400 Baud
dd->req->io_ReadLen   8;     // 8 bit data
dd->req->io_WriteLen  8;     // 8 bit data
dd->req->io_StopBits  1;     // 1 Stop bit
dd->req->io_SerFlags &= ~SERF_PARTY_ON// No Parity
dd->req->io_SerFlags |= SERF_XDISABLED// No Flow Control
err IExec->DoIO( (struct IORequest*)dd->req );
res TRUE;

There is de-init code:

void closeX5000serial(struct DockyData *dd)
dd->dev_open) { IExec->CloseDevice( (struct IORequest*)dd->req ); dd->dev_open FALSE; }
dd->req) { IExec->FreeSysObject(ASOT_IOREQUESTdd->req); dd->req NULL; }
dd->port) { IExec->FreeSysObject(ASOT_PORTdd->port); dd->port NULL; }

Now if we do something like:

dd->dev_open initX5000serial(dd);

We then hit 100% CPU loading every time we query our stuff.

If I remember right, it is correct to open/close the device for every query, right? And it should be not opened all the time?

Any advice is welcome, thanks!

Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: how to work properly with device when you need query every 5 seconds
Just popping in
2008/9/20 23:50
Posts: 65

Whether you should leave a device open or not depends on the use case. Could other programs need to access it in between your accesses? Will your having the device open block other accesses? (I'm too lazy to read the serial.device AutoDoc right now )

Again, I'm not sure of the use case. My guess is you have custom monitoring hardware attached to one of the X5000's serial headers. Or is it standard? Ideally, there would be a hardware monitor API that would share out this information to multiple listeners. Then it wouldn't matter much if the "API" blocked other direct access to the serial device.

   Report Go to top

[Advanced Search]

Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project