Ejemplo n.º 1
0
uint16_t pcl_load(picolInterp *i, uint32_t addr)
{
    uint8_t *ptr = (uint8_t*)addr;
    dbg_send_hex2("pcl_load.addr", (uint32_t)ptr);
    int32_t fsz = (int32_t)flash_fsz1();
    uint32_t len = 0;
    uint16_t rc = PICOL_OK;
    char buf[MAXSTR];
    if(!fsz)
        return rc;
    while(1)
    {
        dbg_send_int2("pcl_load.fsz", fsz);
        while((ptr[0] == 0x0A) && (fsz > 0))
        {
            ptr++;
            fsz--;
        }
        len = pcl_get_chunksz(ptr, fsz);
        dbg_send_int2("pcl_load.len", len);
        if(len == 0)
            break;
        if(len >= sizeof(buf))
        {
            dbg_send_int2("chunk too big", len);
            dbg_send_int2("fsz", fsz);
            dbg_send_int2("ptr", (int32_t)(ptr - addr));
            break;
        }
        mymemcpy(buf, ptr, len);
        buf[len] = 0;
        dbg_send_str3(buf, 1);
        //pcl_exec(buf);
        dbg_send_str3(buf, 1);
        rc = picolEval(i, buf);
        dbg_send_int2("pcl_load_eval_result", rc);
        if(rc != PICOL_OK)
        {
            dbg_send_str3("pcl_load error", 1);
            dbg_send_str3(i->result, 1);
            break;
        }
        ptr += len + 1;
        fsz -= len + 1;
        if(fsz <= 0)
            break;
    }
    dbg_send_int2("pcl_load.fsz", fsz);
    return rc;
}
Ejemplo n.º 2
0
int main(void)
{
    myinit();
    lnah_init();
#ifdef ENABLE_TELNET
    io_recv_str_ptr = telnetd_recv_str;
    io_send_str_ptr = telnetd_send_str;
#endif
#if 0
#ifdef ENABLE_UART
    io_recv_str_ptr = uart_recv_str;
    io_send_str_ptr = uart_send_str;
#endif
#endif
    for (;;)
    {
        lnah_data_upd();
#ifdef ENABLE_PCL
        pcl_io();
#endif
#ifdef ENABLE_VFD
        vfd_upd();
#endif
#ifdef ENABLE_ETH
        eth_io();
        if(myip_tcp_con_closed())
        {
            if((main_evt == EVT_FWUPG) || (main_evt == EVT_REBOOT))
                break;
        }
#endif
    }
    mydeinit();
    dbg_send_int2("reset", main_evt);

#ifdef ENABLE_FLASH
    if(main_evt == EVT_FWUPG)
    {
        flash_copy10();
    }
#endif
    NVIC_SystemReset();
    return 0;
}