2022-01-09 10:28 PM
Hi there,
I have 2 modebus register 0x0010, 0x0011. These are enable encryption
key value. There square vaule should be less then 255 for some reason. This modebus register can be allowed for certain command functions as follows.
void ModebusSetCMD_ENE(void)
{
ModebusSetCMD_Rectifier();
// ENE encryption
{
if(g_ModebusRegister[ENE_RANDUM_NUMBER] && (g_ModebusRegister[ENE_ENCRYPTION_KEY] & 0xFF))
{
g_ModebusRegister[ENE_ENCRYPTION_RESULT] = (g_ModebusRegister[ENE_RANDUM_NUMBER] + (g_ModebusRegister[ENE_ENCRYPTION_KEY] >> 8)) / (g_ModebusRegister[ENE_ENCRYPTION_KEY] & 0xFF);
}
else
{
g_ModebusRegister[ENE_ENCRYPTION_RESULT] = 0xFFFF;
}
}
}
What should I do in the logic to make them less then 225?