From 842bb64195f958b050867c50db66fc0aa413dafb Mon Sep 17 00:00:00 2001 From: QuakeGod <quakegod@sina.com> Date: 星期六, 27 七月 2024 10:42:56 +0800 Subject: [PATCH] KBus upgrade --- ComLib/Src/ModbusRTU.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ComLib/Src/ModbusRTU.c b/ComLib/Src/ModbusRTU.c index f143e6c..88bfb4b 100644 --- a/ComLib/Src/ModbusRTU.c +++ b/ComLib/Src/ModbusRTU.c @@ -236,15 +236,17 @@ case WriteCoil: //5 bit //Store Datas; //SetBitValue(&KMem.WR[Addr1],bitAddr,pPkg->nCount); + Addr1=(Addr&0xfff0)>>4; + bitAddr=Addr&0xf; if (nCount == 0) // set to 0 { - ResetBit(&KMem.WY[Addr1],bitAddr); + if (Addr < 2048) { ResetBit(&KMem.WY[Addr1],bitAddr);} + else {ResetBit(&KMem.WR[Addr1-128],bitAddr);} }else if (nCount == 0xFF00) // set to 1 { - SetAddrBit(&KMem.WY[Addr1],bitAddr); - }else - { - //error + if (Addr < 2048) { SetAddrBit(&KMem.WY[Addr1],bitAddr);} + else {SetAddrBit(&KMem.WR[Addr1-128],bitAddr);} + } memcpy(Pkgbuf,ptr,len); needcrc=0; -- Gitblit v1.9.1