Skip to main content
Md Mubdiul Hasan
Associate III
January 10, 2022
Question

Need a conditional modebus register entry to modebus enable set command

  • January 10, 2022
  • 0 replies
  • 464 views

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?

This topic has been closed for replies.