Hi,
I have a newbie question.
I will write a control program for my telescope. There a three
stepper motors. No hardware inputs at the moment. The steppers
are controlled by a 8255 chip. I must control each bit of the
two ports independent of the other bits.
With the functions:
set bit
reset bit
flip bit
flip bit periodic
To start I have used the example from:
/usr/src/rtlinux-3.0-pre10/examples/frank
with the prepatched kernel 2.2.18.
pthread_make_periodic_np(pthread_self(), gethrtime(), msg.period );
The tasks runs and I can change msg.period with a new msg. It works
great.
Now to the problem. Sometimes i must stop the task and restart the
task later. But if I stop the task with pthread_suspend_np(pthread_self())
I can can not restart the task.
Here is a piece of the code:
...
void *thread_code(void *t)
{
int fifo = (int) t;
int taskno = fifo - 1;
struct my_msg_struct msg;
while (1) {
int ret;
int err;
rtl_printf("Task %d: waiting\n", fifo - 1);
ret = pthread_wait_np();
rtl_printf("Task %d: wakeup\n", fifo - 1);
if ((err = rtf_get (taskno + 1, &msg, sizeof(msg))) == sizeof(msg)) {
// run periodic
if (command == 10) {
pthread_make_periodic_np(pthread_self(), gethrtime(), msg.period );
}
// set bit
if (command == 13) {
set_bit ...
pthread_suspend_np(pthread_self());
}
// stop
if (command == 20) {
pthread_suspend_np(pthread_self());
}
}
...
int my_handler(unsigned int fifo)
{
struct my_msg_struct msg;
int err;
while ((err = rtf_get(17, &msg, sizeof(msg))) == sizeof(msg)) {
rtf_put (msg.kanal + 1, &msg, sizeof(msg));
rtl_printf("FIFO send \"%d\" to task %d; period %d\n", msg.command,
msg.kanal, msg.zeit);
pthread_wakeup_np (tasks [msg.kanal]);
}
if (err != 0) {
return -EINVAL;
}
return 0;
}
I have cut some lines ;)
If I send the msg:
command 10 msg.period = 10000000
and sometimes later the msg
command 10 msg.period = 20000000
it works great
but if I send
command 13 msg.period = 0
it works, but if I send this msg a second time the task at
ret = pthread_wait_np();
will not wake up.
Has anyone a hint for me?
thank you
--
Juergen Liesmann
Hauptstr. 22
27248 Ehrenburg
Germany
Tel.: +49 4275 963030 Fax: +49 721 151 203 706
Email: [EMAIL PROTECTED]
Web: http://www.ra-dec.de
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/