Page 1 of 1

PLCBUS address conversion

Posted: Sat Dec 18, 2010 11:44 pm
by vdoucet
Ron,
I think there is an error in the CPLCBUS.class in the PLCBUStoAddress function.

Code: Select all

497	'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
498	' convert byte to homeunit
499	'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
500	PRIVATE FUNCTION PLCBUStoAddress(bAddress AS Byte) AS String
501	
502	  DIM sHome, sUnit AS String
503	
504	  sHome = Chr((bAddress AND &HF0) + 65)
505	  sUnit = (bAddress AND &H0F) + 1
506	
507	  RETURN sHome & Format(sUnit, "00")
508	
509	END
I think line 504 should read

Code: Select all

sHome = Chr((bAddress AND &HF0) / 16 + 65)
otherwise it works for "A" devices but not for B and above.
Could you check and confirm if I'm right ?