/** This function gets called by the auvr-usb api during usbpoll(), see the api doc for return values and stuff */ usbMsgLen_t usbFunctionSetup(uchar setupData[8]){ usbRequest_t *rq = (usbRequest_t *)setupData; usbMsgPtr = replyBuf; getset = rq->bRequest & 1; port = rq->wIndex.bytes[0]; if(getset == usbmot::get) switch(port){ case 0: case 1: replyBuf[0] = isbitset(PORTC,port); return 1; case 3: return MotorData::serialize(replyBuf,OCR1A << dropmotorres, isbitset(PORTB,4), isbitset(PORTB,5)); case 4: return MotorData::serialize(replyBuf,OCR1B << dropmotorres, isbitset(PORTB,0), isbitset(PORTB,3)); default: replyBuf[0] = 'u'; replyBuf[1] = 'p'; return 2; } else if(getset == usbmot::set) return USB_NO_MSG; else { replyBuf[0] = 'u'; replyBuf[1] = 'c'; return 2; } return 0; }
/* * set read-write error recovery mode page 1 (10 bytes), mmc-6 §7.3. * * requires defect management feature (0x24) mmc-6 §5.3.13 (mandatory on bd, * but has to be enabled by allocating spares with FORMAT UNIT command) * or enhanced defect reporting feature (0x29) mmc-6 §5.3.17, * and they are mutually exclusive. */ static int seterrrecov(Drive *drive) { int n; uint8_t buf[Pagesz]; if (!isbitset(Featdfctmgmt, drive->features) && !isbitset(Featedfctrpt, drive->features)) { fprint(2, "defect mgmt. and enhanced defect reporting disabled!\n"); return -1; } n = mmcgetpage(drive, Pagerrrecov, buf); if (n < 3) return -1; /* n == 255; buf[1] == 10 (10 bytes after buf[1]) */ /* * error recovery page as read: * 0: 01 (page: error recovery) * 1: 0a (length: 10) * 2: c0 (error control bits: 0300 == Erawre|Erarre) * 3: 20 (read retry count: 32) * 4: 00 * 5: 00 * 6: 00 * 7: 00 * 8: 01 (write retry count: 1) * 9: 00 00 00 (error reporting window size) */ buf[0] &= ~(1<<6); /* clear reserved bit */ assert((buf[0] & 077) == Pagerrrecov); assert(buf[1] >= 10); buf[2] = Erawre | Erarre; /* default: Erawre; can't set Ertb */ if (isbitset(Featedfctrpt, drive->features)) buf[7] = 1; /* emcdr: 1==recover, don't tell us; default 0 */ // buf[3] = 32; /* rd retry count; default 32; arbitrary */ // buf[8] = 1; /* wr retry count; default 1; arbitrary */ // memset(buf+9, 0, 3); /* err reporting win siz: 0 == no tsr; default 0 */ if (mmcsetpage(drive, Pagerrrecov, buf) < 0) { if (vflag) fprint(2, "error recovery NOT set\n"); return -1; } if (vflag) fprint(2, "error recovery set\n"); return 0; }
static void processevent(const struct inotify_event *event) { const struct lookfor *l; /* report errors and possible problems */ if (isanybitset(event->mask, IN_DELETE_SELF|IN_UNMOUNT)) { logerror_die("Watched directory vanished!\n"); } if (isbitset(event->mask, IN_Q_OVERFLOW)) { logerror( "Warning: overflow happened! Events might have been missed.\n"); } // debug stuff, to be removed or conditialized: // if (isbitset(event->mask, IN_CREATE)) { // dolog("File was created: %s\n", event->name); // } // if (isbitset(event->mask, IN_CLOSE_WRITE)) { // dolog("File ready: %s\n", event->name); // } // if (isbitset(event->mask, IN_MOVED_TO)) { // dolog("Full file moved here: %s\n", event->name); // } /* look if anything intresting is happening */ if (!isanybitset(event->mask, IN_MOVED_TO|IN_CLOSE_WRITE)) return; for (l = lookfor ; l != NULL ; l = l->next) { if (shouldprocess(l, event->name)) doaction(l, event->name); } }