Exemple #1
0
bool Cmd100::Get_MainConnector(void) {

    // get adress bus
    prev_adrBus = adrBus;
    adrBus = PIN(4) |
            (PIN(18)<<1) |
            (PIN( 6)<<2) |
            (PIN( 3)<<3);


    if (PIN(12) != READ_BIT(port,3)) {
        emit updatedPObject(this);
        update();      // refresh on power ON/OFF
    }

    PUT_BIT(port,0,PIN(25));
    PUT_BIT(port,1,PIN(11));
    PUT_BIT(port,2,PIN(26));
    PUT_BIT(port,3,PIN(12));
    PUT_BIT(port,4,PIN(27));

    data =(  PIN(22) |
            (PIN(19)<<1) |
            (PIN(9)<<2) |
            (PIN(24)<<3) |
            (PIN(21)<<4) |
            (PIN(8)<<5) |
            (PIN(20)<<6) |
            (PIN(23)<<7));

    return true;
}
Exemple #2
0
Fichier : brle.c Projet : S010/test
static size_t
brle_decode(const unsigned char *buf, size_t nbits, unsigned char *outbuf)
{
	size_t		 readp;
	size_t		 writep = 0;
	unsigned char	 bit;
	size_t		 runlen;

	for (readp = 0; readp < nbits; ++readp) {
		bit = BIT_AT(readp);
		++readp;
		for (runlen = 0; BIT_AT(readp); ++readp) {
			runlen <<= 1;
			runlen |= 1;
		}
		PUT_BIT(bit);
		while (runlen--)
			PUT_BIT(bit);
	}

	return writep;
}
Exemple #3
0
Fichier : brle.c Projet : S010/test
static size_t
brle_encode(const unsigned char *buf, size_t size, unsigned char *outbuf)
{
	const size_t	 nbits = size * CHAR_BIT;
	size_t		 readp;
	size_t		 writep = 0;
	size_t		 len;
	size_t		 runlen;
	unsigned char	 bit;

	for (readp = 0; readp < nbits; /*empty*/) {
		bit = BIT_AT(readp);
		len = 1;
		while (readp + len < nbits) {
			if ((bit && BIT_AT(readp + len)) || (!bit && !BIT_AT(readp + len)))
				++len;
			else
				break;
		}
		readp += len;
		do {
			PUT_BIT(bit);
			--len;
			runlen = ~0;
			while (runlen > len)
				runlen >>= 1;
			len -= runlen;
			while (runlen > 0) {
				PUT_BIT(1);
				runlen >>= 1;
			}
			PUT_BIT(0);
		} while (len > 0);
	}

	return writep;

}
Exemple #4
0
bool Cmd100::run(void)
{
    Get_Connector();

    pCONNECTOR_value = pCONNECTOR->Get_values();
    pCENTCONNECTOR_value = pCENTCONNECTOR->Get_values();
    pSIOCONNECTOR_value = pSIOCONNECTOR->Get_values();

    bool P4_GoDown = ( ( P4 == DOWN ) && (prev_P4 == UP)) ? true:false;
    bool P2_GoDown = ( ( P2 == DOWN ) && (prev_P2 == UP)) ? true:false;
    bool P2_GoUp   = ( ( P2 == UP ) && (prev_P2 == DOWN)) ? true:false;


    // Port 27 (P4) from 1 to 0 = reset  : reply 0x55
    if ((P4_GoDown)&&(P2==UP)) {
//    if (P4==UP) {
        AddLog(LOG_PRINTER,tr("MD-100 send 0x55"));
        if (mainwindow->dialoganalogic) mainwindow->dialoganalogic->setMarker(1);
        out_adrBus= 0x03;
        data = 0x55;
        PUT_BIT(port,0,UP);
        FddOpen();
        sendData = true;
    }
    else if (P4==DOWN) {
        if ( P2_GoDown) {

            // Send data
// FDD result send
                PUT_BIT(port,0,UP);
                out_adrBus= 0x03;
//                AddLog(LOG_PRINTER,tr("[%1] MD-100 receivED %2").arg(prev_adrBus,2,16,QChar('0')).arg(data,2,16,QChar('0')));
                data = FddTransfer(data);
                sendData = true;
//                AddLog(LOG_PRINTER,tr("[%1] MD-100 send %2").arg(port,2,16,QChar('0')).arg(data,2,16,QChar('0')));
                if (mainwindow->dialoganalogic) mainwindow->dialoganalogic->setMarker(2);

        }
        else if ( P2_GoUp) {
            // Receive data
            // FDD command received
                sendData = false;
                PUT_BIT(port,0,DOWN);
//                AddLog(LOG_PRINTER,tr("[%1] MD-100 receive %2").arg(prev_adrBus,2,16,QChar('0')).arg(data,2,16,QChar('0')));
                if (mainwindow->dialoganalogic) mainwindow->dialoganalogic->setMarker(3);
        }
        else if (adrBus==0x05) {
            printerDataPort(data);
        }
        else if ((adrBus==0x06))//&&(P2==UP))
        {
            printerControlPort(data);
        }
        else if (adrBus==0x04) {
            // Send the printerStatusPort
            sendData = true;
            out_adrBus = 0x04;
            data = printerStatusPort();
        }
        else if (adrBus == 0x00) {

            // READ
//            serial port status register
//            bit 0 - set when TX buffer full, cleared after the byte has been transmitted
//            bit 1 - set when RX buffer full, cleared after reading the RX data register 010
//            bit 2 - state of the CTS input
//            bit 3 - state of the DSR input
//            bit 4 - state of the DCD input



            // WRITE
//            serial port control register
//            bit 0 - MT/RS232C
//            bit 1 - Odd/Even parity
//            bit 2 - parity OFF/ON
//            bit 3 - 7/8 data length
//            bit 4 - 1/2 stop bit
//            bits 5..7 - baud rate
        }
        else if (adrBus == 0x01) {
            //READ
//            serial port status register
//            bit 0 - set when RX parity error
//            bit 1 - cleared when RX framing or overrun error
//            bit 3 - state of the SW0 input
//            bit 4 - state of the SW1 input
//            bit 5 - state of the SW2 input




            //Write
//            serial port control register
//            bit 0 - transmitter enable
//            bit 1 - receiver enable
//            bit 2 - state of the RTS output
//            bit 3 - state of the DTR output

        }
        else if ( (adrBus == 0x02) && (prev_adrBus != 0x02) ) {
            // READ
//            serial port receive data register
            sendData = true;
            out_adrBus = 0x02;
            data = SIORecvData();
            AddLog(LOG_SIMULATOR,tr("SIO Data received:[%1]=%2").arg(data,2,16,QChar('0')).arg(QChar(data)));

            // WRITE
//            serial port control register
        }
        else if ( (adrBus == 0x03) && (prev_adrBus != 0x03) ){
            // WRITE
//            serial port transmit data register
            AddLog(LOG_SIMULATOR,tr("Data sent to 03:[%1]=%2").arg(data,2,16,QChar('0')).arg(QChar(data)));
        }
    }

//    PUT_BIT(port,3,DOWN); //P3 to 0


    prev_P0 = P0;
    prev_P1 = P1;
    prev_P2 = P2;
    prev_P3 = P3;
    prev_P4 = P4;

    Set_Connector();
    pCONNECTOR_value = pCONNECTOR->Get_values();
    pCENTCONNECTOR_value = pCENTCONNECTOR->Get_values();
    pSIOCONNECTOR_value = pSIOCONNECTOR->Get_values();

    return true;
}