Ejemplo n.º 1
0
void ums_run_once()
{
    uint8_t nextByte;

    // disabled until complete enable string is received
    while (umsEnabled < UMS_ENABLE_LEN && pf_receive_byte(&nextByte) != 0) {
        if (nextByte == UMS_ENABLE[umsEnabled]) {
            ++umsEnabled;
            if (umsEnabled == UMS_ENABLE_LEN) {
            	ums_send_accept();
            }
        } else {
            umsEnabled = 0;
        }
    }

    // not disabled, normal operation
    if (umsEnabled == UMS_ENABLE_LEN) {
        // if the stepper queue is full, then we don't process any more commands
        while (!st_full()) {
            uint8_t *rx = cmd_receive();
            if (rx != NULL) {
                cmd_handler(rx);
            	commandCounter++;
            } else {
                break;
            }
        }
    }

    // send a status when limit switches change or ~1e6 stepper delay ticks have elapsed
    if (umsLimits != previousLimits || umsRunTime > nextStatusTime ||
    		(umsStatus & UMS_SEND_STATUS_NOW) != 0) {
    	previousLimits = umsLimits;
    	nextStatusTime += UMS_STATUS_INTERVAL;
    	ums_send_status();
    	umsStatus &= ~UMS_SEND_STATUS_NOW;
    }
}
Ejemplo n.º 2
0
static int do_send_ums_status(char *cmd)
{
    return ums_send_status();
}