static int fpTransmitterTask(void* dummy) { unsigned char micom_cmd[VFD_MAX_DATA_LEN]; int vLoop; int prev_state = 666, prev_transmitCount = 666; // faked with reason ;) daemonize("fp_transmit"); allow_signal(SIGTERM); while(1) { //wait_event_interruptible(task_wq, (waitAck == 0) && (transmitCount != 0)); /* only send new command if we dont wait already for acknowledge * or we dont wait for a command/answer completion and we have * something to transmit */ if(leaving) { leaving++; break; } if ((state == cStateIdle) && (transmitCount > 0)) { int sendFailed = 0; dprintk("send data to fp (0x%x)\n", transmit[0].command); /* 0. claim sema */ down_interruptible(&transmit_sem); /* 1. send it to the frontpanel */ memset(micom_cmd, 0, VFD_MAX_DATA_LEN); micom_cmd[0] = transmit[0].command; micom_cmd[1] = transmit[0].len + 3; memcpy(micom_cmd + 2, transmit[0].buffer, transmit[0].len); micom_cmd[transmit[0].len + 2] = 0xAA; state = cStateTransmission; int i; for(vLoop = 0 ; vLoop < micom_cmd[1]; vLoop++) { udelay(10000); if (serial3_putc((micom_cmd[vLoop])) == 0) { printk("FP: ERR: sending char = %c \n", micom_cmd[vLoop]); state = cStateIdle; sendFailed = 1; break; } else dprintk(" -> 0x%x\n", micom_cmd[vLoop]); } state = cStateIdle; if (sendFailed == 0) { if (transmit[0].needAck) { waitAckCounter = cMaxAckAttempts; if (transmit[0].isGetter) { timeoutOccured = 0; state = cStateWaitStartOfAnswer; } else state = cStateWaitAck; } else { /* no acknowledge needed so remove it direct */ transmitCount--; memmove(&transmit[0], &transmit[1], (cMaxTransQueue - 1) * sizeof(struct transmit_s)); if (transmitCount != 0) dprintk("%s: next command will be 0x%x\n", __func__, transmit[0].command); } } /* 4. free sem */ up(&transmit_sem); } else { if(state != prev_state || transmitCount != prev_transmitCount) { dprintk("%d, %d\n", state, transmitCount); prev_state = state; prev_transmitCount = transmitCount; } msleep(100); } } printk("FP: task %s stopped\n", __func__); return 0; }
void serial3_puts (const char *s) { while (*s) { serial3_putc (*s++); } }