小R科技-WIFI机器人网·机器人创意工作室

 找回密码
 立即注册
查看: 5979|回复: 1

LUA 语言可以"异或校检"吗? 关于无线WEB发送语音 只差一步

[复制链接]
发表于 2013-8-29 13:41:28 | 显示全部楼层 |阅读模式
本帖最后由 zncs520 于 2013-8-29 14:06 编辑

SYN6288语音实例:
-----------------------------------------------
发送 “欢迎!”语音
fd00090101bbb6d3ada3a185

--------------------语音头文件---------------------------
fd  数据头
00
09 正文长度+3
01
01
------------------语音正文---------------------------
bbb6     欢
d3ad     迎
a3a1      !
----------------尾部异或校检值------------------------------------------------------
85    异或校检值

-----------------------LUA代码-------------------------------------------------------------

#!/usr/bin/lua
io.output("/dev/ttyUSB0")
print [[
Content-Type: text/html
]]
a = string.len(string.sub(os.getenv("QUERY_STRING"),3,-1))+3
b = string.sub(os.getenv("QUERY_STRING"),3,-1)
c = string.char(0xfd,0x00,a,0x01,0x01)

action = {
  ["C0"] = function (x) io.write(string.char(0xff,0x00,x,0x00,0xff)) end,
  ["C1"] = function (x) io.write(string.char(0xff,0x01,0x01,x,0xff)) end,
  ["C2"] = function (x) io.write(string.char(0xff,0x01,0x02,x,0xff)) end,
  ["C3"] = function (x) io.write(string.char(0xff,0x01,0x03,x,0xff)) end,
  ["C4"] = function (x) io.write(string.char(0xff,0x01,0x04,x,0xff)) end,
  ["C5"] = function (x) io.write(string.char(0xff,0x01,0x05,x,0xff)) end,
  ["C6"] = function (x) io.write(string.char(0xff,0x01,0x06,x,0xff)) end,
  ["C7"] = function (x) io.write(string.char(0xff,0x01,0x07,x,0xff)) end,
  ["C8"] = function (x) io.write(string.char(0xff,0x01,0x08,x,0xff)) end,
  ["C9"] = function (x) io.write(string.char(0xff,0x02,x,0x00,0xff)) end,
  ["YY"] = function (x) io.write(string.char(0xfd,0x00,a,0x01,0x01),b,string.char(0x85)) end,
}
print(b)
action[string.sub(os.getenv("QUERY_STRING"),1,2)](string.sub(os.getenv("QUERY_STRING"),3,5))



关于这个85 值
89386b16b7c942e4fa2b33aa10050c2c.jpg



----------------------------语音发送提交方式------------------

http://192.168.1.1/cgi-bin/robotdriver?YY欢迎!









搜索半天资料无果  球教论坛大大!!!


回复

使用道具 举报

 楼主| 发表于 2013-8-30 20:46:07 | 显示全部楼层
本帖最后由 zncs520 于 2013-8-30 21:01 编辑

写了半天
#!/usr/bin/lua
io.output("/dev/ttyUSB0")
print [[
Content-Type: text/html
]]
a = string.len(string.sub(os.getenv("QUERY_STRING"),3,-1))+3
b = string.sub(os.getenv("QUERY_STRING"),3,-1)
c = string.char(0xfd,0x00,a,0x01,0x01)
n = string.char(0xfd,0x00,a,0x01,0x01),b
m = string.byte(string.sub(n,1,1))+string.byte(string.sub(n,2,2))+string.byte(string.sub(n,3,3))+string.byte(string.sub(n,4,4))+string.byte(string.sub(n,5,5))+string.byte(string.sub(b,1,1))+string.byte(string.sub(b,2,2))+string.byte(string.sub(b,3,3))+string.byte(string.sub(b,4,4))+string.byte(string.sub(b,5,5))+string.byte(string.sub(b,6,6))
print (m)
m2 = string.format("%02x ", tostring(m))
print (m2)

i = string.sub(m2,-1,-1)
z = tostring(i)

print(i)

print(b)
action = {
["C0"] = function (x) io.write(string.char(0xff,0x00,x,0x00,0xff)) end,
["C1"] = function (x) io.write(string.char(0xff,0x01,0x01,x,0xff)) end,
["C2"] = function (x) io.write(string.char(0xff,0x01,0x02,x,0xff)) end,
["C3"] = function (x) io.write(string.char(0xff,0x01,0x03,x,0xff)) end,
["C4"] = function (x) io.write(string.char(0xff,0x01,0x04,x,0xff)) end,
["C5"] = function (x) io.write(string.char(0xff,0x01,0x05,x,0xff)) end,
["C6"] = function (x) io.write(string.char(0xff,0x01,0x06,x,0xff)) end,
["C7"] = function (x) io.write(string.char(0xff,0x01,0x07,x,0xff)) end,
["C8"] = function (x) io.write(string.char(0xff,0x01,0x08,x,0xff)) end,
["C9"] = function (x) io.write(string.char(0xff,0x02,x,0x00,0xff)) end,
["YY"] = function (x) io.write(c,b,z) end,
}


action[string.sub(os.getenv("QUERY_STRING"),1,2)](string.sub(os.getenv("QUERY_STRING"),3,5))

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

新品特惠推荐上一条 /2 下一条

QQ|QQ技术咨询1|QQ技术咨询2|商务合作微信1:xiaorgeek001|商务合作微信2:XiaoRGEEK|诚聘英才|Archiver|手机版|小R科技-WIFI机器人网·机器人创意工作室 ( 粤ICP备15000788号-6 )

GMT+8, 2024-11-23 09:28 , Processed in 1.085307 second(s), 22 queries .

Powered by XiaoR GEEK X3.4

© 2014-2021 XiaoR GEEK

快速回复 返回顶部 返回列表