/*
 * print(port:error_tostring(error))
 */
static int lua_port_strerror(lua_State *L)
{
	const char *ret = rs232_strerror((unsigned int) luaL_checkinteger(L, 1));
	if (ret == NULL)
		lua_pushnil(L);
	else
		lua_pushstring(L, ret);

	return 1;
}
Beispiel #2
0
static int init_serial(void)
{
    unsigned int ret = 0;
    port = rs232_init();
    if (port == NULL) return 1;

    rs232_set_device(port, portname);
    ret = rs232_open(port); // open port

    if (ret) 
    {
        printf("%s (%s)\n", rs232_strerror(ret), errno > 0 ? strerror(errno) : "");
        return ret;
    }

    rs232_set_baud(port, RS232_BAUD_115200);
    rs232_flush(port);
    // wait for arduino init
    sleep(3); 
    return 0;
}
Beispiel #3
0
unsigned int err(unsigned int e)
{
	printf("%s (%s)\n", rs232_strerror(e), errno > 0 ? strerror(errno) : "");
	return e;
}