예제 #1
0
void CMainLoop::image(CQtSocket & sock, CXML & packet)
{
	try
	{
		const unsigned current_height = packet["height"].uint(), current_width = packet["width"].uint();
		const unsigned buf_size = current_height * current_width;
		unsigned size, block_size;
		uint8_t * ptr;
		shared_ptr<uint8_t> block_buffer;

		ind = packet["ind"].uint();

		if(height != current_height || width != current_width)
		{
			img.reset(new uint8_t[buf_size], std::default_delete<uint8_t[]>());

			height = current_height;
			width = current_width;
		}

		throw_null(ptr = img.get());

		for(size = 0; size < buf_size; )
		{
			CXML block = sock.recv();

			throw_if(block["command"].uint() != CARD_COMMAND_IMAGE_BLOCK);
			throw_if(block["ind"].uint() != ind);

			protocol::decode_base64(block["data"].value, block_buffer, block_size);

			memcpy(ptr + size, block_buffer.get(), block_size);
			size += block_size;
		}

		emit arinc_write(img.get(), height, width);
	}
	catch(...)
	{
		;
	}
}
예제 #2
0
void test_arinc_main()
{
    debug_printf("func_tx = %x, control1_tx = %x\n", func_tx, control1_tx);
    debug_printf("func_rx = %x, control1_rx = %x, control2_rx = %x\n", func_rx, control1_rx, control2_rx);

    debug_printf("channel out = %d, in = %d\n", MY_OUT_CHANNEL, MY_IN_CHANNEL);
    debug_printf("ssm data sdi label\n");

    unsigned int counter = 0xee;
    ARINC_msg_t *const pCounter = (ARINC_msg_t *)&counter;
    pCounter->label = 0x30;
    pCounter->sdi = 1;
    pCounter->data = 0x1f;

    const int fifoCnt = 60;
    int i = 0;
    unsigned int data = 0;
    ARINC_msg_t *const pData = (ARINC_msg_t *)&data;

    int received = 0;

    unsigned long time0 = timer_milliseconds(&timer);

    for(;;)
    {
//        const ARINC_msg_t firstSentData = *pCounter;

        for (i=0; i<fifoCnt; ++i)
        {
            arinc_write(&atx, *pCounter);

            debug_printf("sent = %x = %x %x %x %x, status = %x\n", counter, pCounter->ssm, pCounter->data, pCounter->sdi, pCounter->label, ARM_ARINC429T->STATUS);
            ++counter;
        }

        for(;;)
        {
            if (arinc_read(&arx, pData))
            {
                ++received;
                debug_printf("received=%08x (ssm=%x data=%x sdi=%x label=%x), status1 = %x, status2 = %x\n",
                		data, pData->ssm, pData->data, pData->sdi, pData->label, ARM_ARINC429R->STATUS1, ARM_ARINC429R->STATUS2);

                // debug
                if (timer_passed(&timer, time0, 1000))
                {
                    static int ddd = 0;
                    if (ddd == 0)
                        debug_printf("received frames cnt = %d                      -------------\n", received);
                    ddd = 1;
                }
            }
            else
            {
                if ((ARM_ARINC429R->STATUS1 & ARM_ARINC429R_STATUS1_ERR(MY_IN_CHANNEL)) > 0)
                {
                    // Ошибка приёма
                    debug_printf("rec error\n");
                }
                else
                {
                    debug_printf("no data received\n");
                }
                break;
            }
        }

        timer_delay(&timer, 1000);
//        mdelay(1000);
    }
}