威纶通官方论坛

请高手帮忙想个办法,自由通讯宏指令

[复制链接]
发表于 2012-9-10 18:16:57 | 显示全部楼层 |阅读模式
4个数据包,每个包的数据是变化的,要求循环发送4个数据包。
我用FOR----NEXT命令无法实现:开机只发送一次第一个数据包,重复发四次;然后就一直只发最后一个数据包,每次重复发4次
用IF----END IF命令倒是实现了,就是发送速度慢的吓人,基本1到2秒一个数据包。
IF----END IF指令程序如下:
macro_command main()
char data[9]
int w,x
data[0]=0x7E
data[2]=0x00
data[4]=0x00
data[5]=0x00
data[6]=0x00
data[7]=0x02
data[8]=0x7E
select case x
CASE 0
data[1]=0x00
data[3]=0xED
break
CASE 1
data[1]=0x02
data[3]=0x2c
break
CASE 3
data[1]=0x03
data[3]=0xDF
break
CASE 4
data[1]=0x04
data[3]=0x01
break
end select
if w<4 then
x=w
OUTPORT(data[0],"free",9)
end if
w=w+1
if w==4 then
w=0
end if
end macro_command
FOR----NEXT指令程序如下:
macro_command main()
char data[9]
int w,x

data[0]=0x7E
data[2]=0x00
data[4]=0x00
data[5]=0x00
data[6]=0x00
data[7]=0x02
data[8]=0x7E

select case x
CASE 0
data[1]=0x00
data[3]=0xED
break
CASE 1

data[1]=0x02
data[3]=0x2c

break
CASE 3


data[1]=0x03
data[3]=0xDF

break
CASE 4

data[1]=0x04
data[3]=0x01

break

end select

W=0
FOR  w=0 TO 4
x=w
OUTPORT(data[0],"free",9)
NEXT w
end macro_command
麻烦高手们帮我想个办法!
发表于 2012-9-17 09:21:54 | 显示全部楼层
你试一下这段宏指令,在系统参数设置中勾选“开机后使用初始化宏指令"执行这段程序就可以。
macro_command main()
char data[9]
int w,x
data[0]=0x7E
data[2]=0x00
data[4]=0x00
data[5]=0x00
data[6]=0x00
data[7]=0x02
data[8]=0x7E
while 1
for w=0 to 3
   x=w
   select case x
   case 0
     data[1]=0x00
     data[3]=0xED
   break
   case 1
     data[1]=0x02
     data[3]=0x2c
   break
   case 2
     data[1]=0x03
     data[3]=0xDF
   break
   case 3
     data[1]=0x04
     data[3]=0x01
   end select
   OUTPORT(data[0], "Free Protocol", 9)
   DELAY(500)
next w
wend
end macro_command
发表于 2012-9-17 09:22:10 | 显示全部楼层
你试一下这段宏指令,在系统参数设置中勾选“开机后使用初始化宏指令"执行这段程序就可以。
macro_command main()
char data[9]
int w,x
data[0]=0x7E
data[2]=0x00
data[4]=0x00
data[5]=0x00
data[6]=0x00
data[7]=0x02
data[8]=0x7E
while 1
for w=0 to 3
   x=w
   select case x
   case 0
     data[1]=0x00
     data[3]=0xED
   break
   case 1
     data[1]=0x02
     data[3]=0x2c
   break
   case 2
     data[1]=0x03
     data[3]=0xDF
   break
   case 3
     data[1]=0x04
     data[3]=0x01
   end select
   OUTPORT(data[0], "Free Protocol", 9)
   DELAY(500)
next w
wend
end macro_command
您需要登录后才可以发帖 登录 | 注册

本版积分规则

回复帖子

Archiver|小黑屋|威纶通官网 ( 粤ICP备06054553号 )

GMT+8, 2024-5-16 18:08

Powered by Discuz! X3.4

© 2001-2023 Comsenz Inc.

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