rt_err_t rym_write_to_file(rt_device_t idev) { rt_err_t res; struct custom_ctx *ctx = rt_malloc(sizeof(*ctx)); RT_ASSERT(idev); rt_kprintf("entering RYM mode\n"); res = rym_recv_on_device(&ctx->parent, idev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX, _rym_bg, _rym_tof, _rym_end, 1000); /* there is no Ymodem traffic on the line so print out info. */ rt_kprintf("leaving RYM mode with code %d\n", res); rt_kprintf("file %s has been created.\n", ctx->fpath); rt_free(ctx); return res; }
rt_err_t rym_cat_to_dev(rt_device_t idev, rt_device_t odev) { struct rym_ctx rctx; rt_err_t res; _odev = odev; rt_kprintf("entering RYM mode\n"); odev->flag &= ~RT_DEVICE_FLAG_STREAM; res = rt_device_open(odev, 0); if (res != RT_EOK) { rt_kprintf("open output device error: 0x%x", -res); return res; } res = rym_recv_on_device(&rctx, idev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX, RT_NULL, _rym_echo_data, RT_NULL, 1000); rt_device_close(_odev); rt_kprintf("leaving RYM mode with code %X\n", res); return res; }