- Joined
- Nov 24, 2014
- Messages
- 3,162
- Trophies
- 2
- Age
- 29
- Location
- Bologna
- Website
- rinnegatamante.it
- XP
- 4,857
- Country
Does someone knows how IR service works with ctrulib? (For example: https://github.com/smealum/ctrulib/blob/master/libctru/include/3ds/services/ir.h what flag is for RecvData).
I tried to write a simple string sender/receiver without success. These are the functions i wrote to test but i get no data received:
I tried to write a simple string sender/receiver without success. These are the functions i wrote to test but i get no data received:
Code:
static int lua_receive(lua_State *L){
int argc = lua_gettop(L);
if (argc != 0) return luaL_error(L, "wrong number of arguments");
char result[2048];
u32 received_bytes = 0;
while (received_bytes == 0){
IRU_RecvData((u8*)&result, 2048, 0x00, &received_bytes, 1);
}
u32 confirm = 0xDEAD;
IRU_SendData((u8*)confirm, 4, 1);
lua_pushlstring(L,result,received_bytes);
return 1;
}
static int lua_send(lua_State *L){
int argc = lua_gettop(L);
if (argc != 1) return luaL_error(L, "wrong number of arguments");
const char *data = luaL_checkstring(L, 1);
u32 result = 0x0000;
u32 received_bytes;
while (result != 0xDEAD){
IRU_SendData((u8*)data, strlen(data), 1);
IRU_RecvData((u8*)&result, 4, 0x00, &received_bytes, 1);
}
return 0;
}