Beispiel #1
0
uint8_t
xpcc::MAX6966<Spi, Cs, DRIVERS>::getChannel(uint16_t channel)
{
	if (channel >= DRIVERS*10)
		return 0;
	
	uint8_t driver = channel / 10;
	uint8_t reg = channel % 10;
	
	return readFromDriver(driver, static_cast<max6966::Register>(reg));
}
Beispiel #2
0
		static inline void
		writeToDriverMasked(uint8_t driver, max6966::Register reg, uint8_t data, uint8_t mask)
		{
			uint8_t readout = readFromDriver(driver, reg);
			writeToDriver(driver, reg, (data & mask) | (readout & ~mask));
		}
Beispiel #3
0
		/// get Chip configuration
		static inline uint8_t
		getConfiguration(uint8_t driver=0)
		{
			return readFromDriver(driver, max6966::REGISTER_CONFIGURATION);
		}
Beispiel #4
0
/* service traffic from clients and drivers */
void
indiRun(void)
{
	fd_set rs, ws;
        int maxfd=0;
	int i, s;

	/* init with no writers or readers */
	FD_ZERO(&ws);
	FD_ZERO(&rs);

        if (fifo.name && fifo.fd >=0)
        {
           FD_SET(fifo.fd, &rs);
           maxfd = fifo.fd;
        }

	/* always listen for new clients */
	FD_SET(lsocket, &rs);
        if (lsocket > maxfd)
                maxfd = lsocket;

	/* add all client readers and client writers with work to send */
	for (i = 0; i < nclinfo; i++) {
	    ClInfo *cp = &clinfo[i];
	    if (cp->active) {
		FD_SET(cp->s, &rs);
		if (nFQ(cp->msgq) > 0)
		    FD_SET(cp->s, &ws);
		if (cp->s > maxfd)
		    maxfd = cp->s;
	    }
	}

	/* add all driver readers and driver writers with work to send */
        for (i = 0; i < ndvrinfo; i++)
        {
	    DvrInfo *dp = &dvrinfo[i];
            if (dp->active)
            {
                FD_SET(dp->rfd, &rs);
                if (dp->rfd > maxfd)
                   maxfd = dp->rfd;
                if (dp->pid != REMOTEDVR)
                {
                   FD_SET(dp->efd, &rs);
                   if (dp->efd > maxfd)
                      maxfd = dp->efd;
                }
                if (nFQ(dp->msgq) > 0)
                {
                   FD_SET(dp->wfd, &ws);
                   if (dp->wfd > maxfd)
                       maxfd = dp->wfd;
                }
            }
	}

	/* wait for action */
	s = select (maxfd+1, &rs, &ws, NULL, NULL);
	if (s < 0) {
	    fprintf (stderr, "%s: select(%d): %s\n", indi_tstamp(NULL), maxfd+1,
							    strerror(errno));
	    Bye();
	}


        /* new command from FIFO? */
        if (s > 0 && fifo.fd >= 0 && FD_ISSET(fifo.fd, &rs))
        {
            newFIFO();
            s--;
        }

	/* new client? */
	if (s > 0 && FD_ISSET(lsocket, &rs)) {
	    newClient();
	    s--;
	}

	/* message to/from client? */
	for (i = 0; s > 0 && i < nclinfo; i++) {
	    ClInfo *cp = &clinfo[i];
	    if (cp->active) {
		if (FD_ISSET(cp->s, &rs)) {
		    if (readFromClient(cp) < 0)
			return;	/* fds effected */
		    s--;
		}
		if (s > 0 && FD_ISSET(cp->s, &ws)) {
		    if (sendClientMsg(cp) < 0)
			return;	/* fds effected */
		    s--;
		}
	    }
	}

	/* message to/from driver? */
	for (i = 0; s > 0 && i < ndvrinfo; i++) {
	    DvrInfo *dp = &dvrinfo[i];
	    if (dp->pid != REMOTEDVR && FD_ISSET(dp->efd, &rs)) {
		if (stderrFromDriver(dp) < 0)
		    return;	/* fds effected */
		s--;
	    }
	    if (s > 0 && FD_ISSET(dp->rfd, &rs)) {
        if (readFromDriver(dp) < 0)
            return;	/* fds effected */
		s--;
	    }
	    if (s > 0 && FD_ISSET(dp->wfd, &ws) && nFQ(dp->msgq) > 0) {
        if (sendDriverMsg(dp) < 0)
           return;	/* fds effected */
		s--;
	    }
	}
}