static void handle_message(struct cfw_message *msg, void *param)
{
	switch (CFW_MESSAGE_ID(msg)) {
	case MSG_ID_CIRCULAR_STORAGE_PUSH_REQ:
		handle_push(msg);
		break;
	case MSG_ID_CIRCULAR_STORAGE_POP_REQ:
		handle_pop(msg);
		break;
	case MSG_ID_CIRCULAR_STORAGE_PEEK_REQ:
		handle_peek(msg);
		break;
	case MSG_ID_CIRCULAR_STORAGE_CLEAR_REQ:
		handle_clear(msg);
		break;
	case MSG_ID_LL_CIRCULAR_STORAGE_SHUTDOWN_REQ:
		cfw_send_message(CFW_MESSAGE_PRIV(msg));
		break;
	case MSG_ID_CIRCULAR_STORAGE_GET_REQ:
		handle_get(msg);
	default:
		cfw_print_default_handle_error_msg(LOG_MODULE_MAIN,
						   CFW_MESSAGE_ID(
							   msg));
		break;
	}

	cfw_msg_free(msg);
}
Beispiel #2
0
template<typename Config> void SystemSetupConsole<Config>::loop(void)
{
#if SETUP_OVER_SERIAL1
    //TRY_LOCK(SETUP_SERIAL)
    {
        if (setup_serial1() && s_tester_handlers.size != 0) {
            int c = -1;
            if (SETUP_SERIAL.available()) {
                c = SETUP_SERIAL.read();
            }
            if (SETUP_LISTEN_MAGIC) {
                static uint8_t magic_code[] = { 0xe1, 0x63, 0x57, 0x3f, 0xe7, 0x87, 0xc2, 0xa6, 0x85, 0x20, 0xa5, 0x6c, 0xe3, 0x04, 0x9e, 0xa0 };
                if (!serial1Enabled) {
                    if (c>=0) {
                        if (c==magic_code[magicPos++]) {
                            serial1Enabled = magicPos==sizeof(magic_code);
                            if (serial1Enabled) {
                                if (tester == nullptr && s_tester_handlers.create != nullptr) {
                                    tester = s_tester_handlers.create(nullptr);
                                }
                                if (tester != nullptr && s_tester_handlers.setup) {
                                    s_tester_handlers.setup(tester, SETUP_OVER_SERIAL1, nullptr);
                                }
                            }
                        }
                        else {
                            magicPos = 0;
                        }
                        c = -1;
                    }
                }
                else {
                    if (tester != nullptr && s_tester_handlers.loop) {
                        s_tester_handlers.loop(tester, c, nullptr);
                    }
                }
            }
        }
    }
#endif

    TRY_LOCK(serial)
    {
        if (serial.available())
        {
            int c = serial.peek();
            if (c >= 0)
            {
                if (!handle_peek((char)c))
                {
                    if (serial.available())
                    {
                        c = serial.read();
                        handle((char)c);
                    }
                }
            }
        }
    }
}
static void handle_message(struct cfw_message * msg, void * param)
{
    switch (CFW_MESSAGE_ID(msg)) {
    case MSG_ID_LL_ERASE_BLOCK_REQ:
        handle_erase_block(msg);
        break;
    case MSG_ID_LL_READ_PARTITION_REQ:
        handle_read_partition(msg);
        break;
    case MSG_ID_LL_WRITE_PARTITION_REQ:
        handle_write_partition(msg);
        break;
#ifdef CONFIG_SERVICES_QUARK_SE_STORAGE_CIRCULAR
    case MSG_ID_LL_CIR_STOR_INIT_REQ:
        handle_cir_stor_init(msg);
        break;
    case MSG_ID_LL_PUSH_REQ:
        handle_push(msg);
        break;
    case MSG_ID_LL_POP_REQ:
        handle_pop(msg);
        break;
    case MSG_ID_LL_PEEK_REQ:
        handle_peek(msg);
        break;
    case MSG_ID_LL_CLEAR_REQ:
        handle_clear(msg);
        break;
#endif
    default:
        cfw_print_default_handle_error_msg(LOG_MODULE_MAIN, CFW_MESSAGE_ID(msg));
        break;
    }

    cfw_msg_free(msg);
}