QuakeGod
2024-02-25 95322c84888cbe2e92024d4d65698f59b016cb52
ComLib/Src/ModbusRTU.c
@@ -168,11 +168,18 @@
            bitmask=1;
            for (int j=0;j<8&&i*8+j<nCount;j++)
            {
               Addr1=(Addr&0xff0)>>4;
               Addr1=(Addr&0xfff0)>>4;
               bitAddr=Addr&0xf;
               if (GetBitValue( KMem.WY[Addr1],bitAddr))
               {
                  thisValue|=bitmask;
               if (Addr < 2048) {
                  if (GetBitValue( KMem.WY[Addr1],bitAddr))
                  {
                     thisValue|=bitmask;
                  }
               }else {
                  if (GetBitValue( KMem.WR[Addr1-128],bitAddr))
                  {
                     thisValue|=bitmask;
                  }
               }
               bitmask<<=1;
               Addr++;
@@ -260,10 +267,13 @@
            bitmask=1;
            for (int j=0;j<8&&i*8+j<nCount;j++)
            {
               Addr1=(Addr&0xff0)>>4;
               Addr1=(Addr&0xfff0)>>4;
               bitAddr=Addr&0xf;
               SetBitValue( &KMem.WY[Addr1],bitAddr,bitmask&thisValue);
               if (Addr < 2048) {
                  SetBitValue( &KMem.WY[Addr1],bitAddr,bitmask&thisValue);
               } else {
                  SetBitValue( &KMem.WR[Addr1 - 128],bitAddr,bitmask&thisValue);
               }
               bitmask<<=1;
               Addr++;
            }