|
Linux Fast Parallel Port Control using Allegro |
Randall Dodson
Member #5,205
November 2004
|
Here is some parallel port routines that I am using to control some hardware that is attached to my parallel port. The writes seem to work, don't know about the reads yet. The main problem is that the reads and the writes seem to take way too long to execute. Any suggestions on if the linux code is correct or on speeding up the parallel port routines? Thanks. #include "allegro.h" // Parallel Port struct timespec ts; int Main(){ //Write to Parallel Port close_parallel_port(); } END_OF_MAIN(); toggle_strobe(){ toggle_init(){ initialize_port_signals(){ open_parallel_port(){ printf("data: %x\n", inb(DATA)); usleep(1000); close_parallel_port(){ if (ioperm (DATA,3,TURN_OFF)) return 0; |
A J
Member #3,025
December 2002
|
you know how to time things, what bit takes too long ? ___________________________ |
Randall Dodson
Member #5,205
November 2004
|
I have decided to use parapin.c and parapin.h routines for parallel port control. Theses routines seem to work pretty well. But, the "nanosleep(&ts, NULL);" which I have set to delay 500nsec takes several milliseconds to execute for some reason? Does anybody know, using linux, how to delay 500nsec +/- 100nsec? Thanks for your help. |
Evert
Member #794
November 2000
|
Quote: Does anybody know, using linux, how to delay 500nsec +/- 100nsec? I'm not sure you can do that reliably. The nanosleep manpage says the manpage said:
BUGS As some applications require much more precise pauses I think other functions that try to do the same thing would have similar limitations and problems. |
Randall Dodson
Member #5,205
November 2004
|
Thanks for pointing out the bug when using "nanosleep". I will now attempt to use the scheduling functions that you mentioned. Has anyone done any "hard" real time loops using linux? Here's what I want to do: while(1){ //slot2 stuff - This slot takes 0.25msec to execute //and so on with each slot consuming 0.25msec of time Maybe I need to learn how to use the hardware timers on the Processor Board. Has anyone done this? |
A J
Member #3,025
December 2002
|
maybe you need to realize that a multi-threaded environment means you have NO way of guaranteeing your thread is on the CPU when you want it. best effort, and that is ALL it will be (whilst using a multi-threaded OS), is you create a REAL_TIME or TIME_CRITICAL thread and you completely hog the CPU and do NOT use any OS rest() / yield() functions. ___________________________ |
Randall Dodson
Member #5,205
November 2004
|
Thanks for the advise. On my project, the complete CPU will be dedicated to executing my program. I will be checking into the REAL_TIME or TIME_CRITICAL threads. My goal is to have 16 processing slots that continuous repeat, with each slot lasting 0.25ms. A processing loop takes 4ms. During each slot, parallel port reads and writes are occuring, allegro graphics screens are showing and sound clips are playing. Any additional advise is welcomed. |
A J
Member #3,025
December 2002
|
Quote: Any additional advise is welcomed. if you are still considering real-time, time critical, on-the-msec accuracy, you are dreamin! you want to do time critical, graphics, and audio.. you must have next to zero clue about how your CPU/OS works. stop coding, go read about how your multi-tasking OS works. ___________________________ |
|