Browse Source

add xtty.cmd(cmd, rw, subtype, data)

Signed-off-by: surenyi <surenyi82@163.com>
master
surenyi 7 years ago
parent
commit
453962e031
  1. 1
      .gitignore
  2. 21
      src/icd.c
  3. 10
      src/xtty.c
  4. 1
      src/xtty.h

1
.gitignore

@ -12,3 +12,4 @@ src/__pycache__
src/icd.json
src/cjson.so
libraries/lib.amd64
icd-rf-release.tar.gz

21
src/icd.c

@ -631,11 +631,32 @@ static int func_xtty_set_volume(lua_State *L)
return 0;
}
static int func_xtty_cmd(lua_State *L)
{
int cmd, rw, subtype;
const char *dt = NULL;
size_t len = 0;
int r;
cmd = luaL_checkinteger(L, 1); /* cmd code */
rw = luaL_checkinteger(L, 2); /* rw code */
subtype = luaL_checkinteger(L, 3); /* subtype code */
if (lua_gettop(L) >= 4) {
dt = luaL_checklstring(L, 4, &len);
}
r = xtty_cmd_generic(cmd, rw, subtype, dt, len);
lua_pushboolean(L, r == 0);
return 1;
}
static int luaopen_xtty(lua_State *L)
{
static luaL_Reg funcs[] = {
{"init", func_xtty_init},
{"exit", func_xtty_exit},
{"cmd", func_xtty_cmd},
{"set_ingress", func_xtty_ingress},
{"set_channel", func_xtty_set_channel},
{"set_freq", func_xtty_set_freq},

10
src/xtty.c

@ -173,7 +173,17 @@ int xtty_set_volume(int _vol)
if (vol >= 1 && vol <= 9) {
if (__reader && __reader->proto) {
xproto_send(__reader->proto, XCMD_TYPE_W, XCMD_VOLUME, XPROTO_STYPE_SET, &vol, 1);
return 0;
}
}
return -1;
}
int xtty_cmd_generic(int cmd, int rw, int subtype, const void *data, int len)
{
if (__reader && __reader->proto) {
xproto_send(__reader->proto, rw, cmd, subtype, (void *)data, len);
return 0;
}
return -1;
}

1
src/xtty.h

@ -7,6 +7,7 @@ void xtty_set_ingress(void (*ingress)(void *ud, int type, int cmd, unsigned char
int xtty_change_channel(int ch);
int xtty_set_volume(int vol);
int xtty_scan_freq(int _en);
int xtty_cmd_generic(int cmd, int rw, int subtype, const void *data, int len);
int xtty_set_freq(double rx, double tx);

Loading…
Cancel
Save