发表于:2007-01-06 10:05:00
楼主
此程序为发送请求节点,接收不到返回的响应
用lonscanner可看到request和respond数据包,子网号和节点号都对
when (io_changes(ioButton))
{
msg_out.code = DATA_REQUEST;
msg_out.tag = TAG_OUT1;
msg_out.dest_addr.snode.domain=0;
msg_out.dest_addr.snode.node=5;
msg_out.dest_addr.snode.subnet=1;
msg_out.service=REQUEST;
msg_out.dest_addr.snode.type=1;
msg_out.data[0]=5;
msg_out.data[1]=6;
msg_send();
}
#pragma scheduler_reset
//when(msg_arrives)
//{
// switch(msg_in.code)
// {
// case METER_LED_ON:
// MeterSetLed (TRUE);
// break;
// case METER_LED_OFF:
// MeterSetLed (FALSE);
// break;
// default:
// break;
// }
//}
when(msg_arrives(0))
{
MeterSetLed (TRUE);
}
when(msg_arrives(1))
{
MeterSetLed (FALSE);
}
when(resp_arrives)
{
MeterSetLed (TRUE);
//if(resp_in.code == OK){
//for(i=0;i<resp_in.data[0];++i){
// watchdog_update();
// MeterSetLed (FALSE);
// delay(19838);
// watchdog_update();
// MeterSetLed (TRUE);
// delay(19838);
// watchdog_update();
//}
//}
}
//此程序为发送响应的节点
when(msg_arrives)
{
switch(msg_in.code)
{
case METER_LED_ON:
MeterSetLed (TRUE);
break;
case METER_LED_OFF:
MeterSetLed (FALSE);
break;
case DATA_REQUEST:
MeterSetLed (TRUE);
resp_out.code = OK;
resp_out.data[0]=2;
resp_send();
break;
default:
break;
}
}
请高手们指教!