|
|
@@ -437,10 +437,10 @@ void ProtocolImpl::sendAllocFrame(PBYTE pbuf, int id, int &len)
|
|
437
|
437
|
pbuf[5] = static_cast<uint8_t>(maxId); // 转换为字节
|
|
438
|
438
|
pbuf[6] = static_cast<uint8_t>(orderMode); // 转换为字节
|
|
439
|
439
|
pbuf[7] = static_cast<uint8_t>(orderState); // 转换为字节
|
|
440
|
|
- pbuf[8] = 0;
|
|
441
|
|
- pbuf[9] = 0;
|
|
442
|
|
- pbuf[10] = 0;
|
|
443
|
|
- pbuf[11] = 0;
|
|
|
440
|
+// pbuf[8] = 0;
|
|
|
441
|
+// pbuf[9] = 0;
|
|
|
442
|
+// pbuf[10] = 0;
|
|
|
443
|
+// pbuf[11] = 0;
|
|
444
|
444
|
// 打印调试信息
|
|
445
|
445
|
log_i("发送分配地址帧: ");
|
|
446
|
446
|
for (int i = 0; i < 8; i++) {
|
|
|
@@ -448,7 +448,7 @@ void ProtocolImpl::sendAllocFrame(PBYTE pbuf, int id, int &len)
|
|
448
|
448
|
}
|
|
449
|
449
|
currentState = RECEIVED ;
|
|
450
|
450
|
|
|
451
|
|
- len = 12;
|
|
|
451
|
+ len = 8;
|
|
452
|
452
|
|
|
453
|
453
|
}
|
|
454
|
454
|
|
|
|
@@ -565,7 +565,9 @@ HRESULT ProtocolImpl::onRead(Device *pdevice, Packet *ppacket, Item *pitem,
|
|
565
|
565
|
if(currentState == INIT)
|
|
566
|
566
|
{
|
|
567
|
567
|
initIO();
|
|
|
568
|
+ sendDelay = 0;
|
|
568
|
569
|
}
|
|
|
570
|
+
|
|
569
|
571
|
if(currentState == SEND)
|
|
570
|
572
|
{
|
|
571
|
573
|
sendAllocFrame(pbuf,currentId , len);
|
|
|
@@ -573,6 +575,7 @@ HRESULT ProtocolImpl::onRead(Device *pdevice, Packet *ppacket, Item *pitem,
|
|
573
|
575
|
//pdevice->getBase().setRwstate(READ_WAIT);
|
|
574
|
576
|
pdevice->getBase().setRwstate(WRITE_WAIT);
|
|
575
|
577
|
}
|
|
|
578
|
+
|
|
576
|
579
|
if(currentState == RECEIVED)
|
|
577
|
580
|
{
|
|
578
|
581
|
if(timeOut > 30)
|
|
|
@@ -588,56 +591,7 @@ HRESULT ProtocolImpl::onRead(Device *pdevice, Packet *ppacket, Item *pitem,
|
|
588
|
591
|
return S_OK;
|
|
589
|
592
|
}
|
|
590
|
593
|
|
|
591
|
|
-// if(findAddrFlag == 0)
|
|
592
|
|
-// {
|
|
593
|
|
-// log_i("寻址标志是0");
|
|
594
|
|
-// if(currentId == 1)
|
|
595
|
|
-// {
|
|
596
|
|
-// //setGpioDetrict();
|
|
597
|
|
-//
|
|
598
|
|
-// // 设置 GPIO 436 为高电平
|
|
599
|
|
-// log_i("计数count = %d",count);
|
|
600
|
|
-// if(count == 1)
|
|
601
|
|
-// {
|
|
602
|
|
-// if (set_gpio_value(devPath, lowLevel) == 0)
|
|
603
|
|
-// {
|
|
604
|
|
-// log_i("Set GPIO 436 to high");
|
|
605
|
|
-// }
|
|
606
|
|
-// else
|
|
607
|
|
-// {
|
|
608
|
|
-// log_e("Failed to set GPIO 436 to high");
|
|
609
|
|
-// }
|
|
610
|
|
-// }
|
|
611
|
|
-//
|
|
612
|
|
-// else
|
|
613
|
|
-// {
|
|
614
|
|
-// if(count > 4)
|
|
615
|
|
-// {
|
|
616
|
|
-// // 设置 GPIO 436 为低电平
|
|
617
|
|
-// if (set_gpio_value(devPath, highLevel) == 0)
|
|
618
|
|
-// {
|
|
619
|
|
-// log_i("Set GPIO 436 to low");
|
|
620
|
|
-// }
|
|
621
|
|
-// else
|
|
622
|
|
-// {
|
|
623
|
|
-// log_e("Failed to set GPIO 436 to low");
|
|
624
|
|
-// }
|
|
625
|
|
-// sendAllocFrame(pbuf,currentId , len);
|
|
626
|
|
-// count = 0;
|
|
627
|
|
-// }
|
|
628
|
|
-// }
|
|
629
|
|
-// count ++;
|
|
630
|
|
-//
|
|
631
|
|
-//
|
|
632
|
|
-// }
|
|
633
|
|
-// if()
|
|
634
|
|
-// {
|
|
635
|
|
-// sendAllocFrame(pbuf,currentId , len);
|
|
636
|
|
-// }
|
|
637
|
|
-// log_i("len的长度:%d",len);
|
|
638
|
|
-// return S_OK;
|
|
639
|
|
-
|
|
640
|
|
- //}
|
|
|
594
|
+
|
|
641
|
595
|
if(currentState == END)
|
|
642
|
596
|
//if(findAddrFlag == 1)
|
|
643
|
597
|
{
|