Needed for ProductID Register of Ethercat Core
In [3]:
def gen_product_id(version="1.2.3", product_type="Ricoh", image_type="User"):
version_norm = version.lower()
product_type = product_type.lower()
image_type = image_type.lower()
# Calculate Version
version_split = version_norm.split(".")
version_int = int(version_split[0])*1000000 + int(version_split[1])*1000 + int(version_split[2])*1
version_hex = hex(version_int)[2:]
version_msb = version_hex[:-4]
version_lsb = version_hex[-4:]
print("Ethercat Product ID Registers")
print("-----------------------------")
# Product ID 3
print("Product Version = {:09} : Product ID 3: 0x0000000{:}".format(version_int,version_msb))
# Product ID 2
print(" : Product ID 2: 0x0000{}".format((version_lsb)))
# Product ID 1
if product_type == "ricoh":
print("Product Type = Ricoh : Product ID 1: 0x00005249")
elif product_type == "konicaminolta":
print("Product Type = KonicaMinolta : Product ID 1: 0x00004B4D")
elif product_type == "kyocera":
print("Product Type = Kyocera : Product ID 1: 0x00004B59")
elif product_type == "generic":
print("Product Type = Generic : Product ID 1: 0x00004745")
elif product_type == "xaar":
print("Product Type = Xaar : Product ID 1: 0x00005841")
else:
print("Product Type = Unknown : Product ID 1: 0x0000????")
# Product ID 0
if image_type == "user":
print("Image Type = User : Product ID 0: 0x00005355")
elif image_type == "factory":
print("Image Type = Factory : Product ID 0: 0x00004146")
else:
print("Image Type = Unknown : Product ID 0: 0x0000????")
print("")
def gen_system_manager(version="1.2.3.0", product_type="Kyocera", printhead_type="KJ4B_QA06NTB_STDV_4B", image_type="User"):
version_norm = version.lower()
product_type = product_type.lower()
image_type = image_type.lower()
printhead_type = printhead_type.lower()
# Calculate Version
version_split = version_norm.split(".")
version_int = int(version_split[0])*2**24 + int(version_split[1])*2**16 + int(version_split[2])*2**8 + int(version_split[3])*2**0
print("System Management Registers")
print("---------------------------")
# FPGA Version
print("FPGA Version : 0x{:08X}".format(version_int))
# Product Type
if product_type == "generic":
product_type_msb = 0
elif product_type == "kyocera":
product_type_msb = 1
elif product_type == "konicaminolta":
product_type_msb = 2
elif product_type == "ricoh":
product_type_msb = 3
elif product_type == "xaar":
product_type_msb = 4
else:
product_type_msb = -1
if printhead_type == "generic":
product_type_lsb = 0
elif printhead_type == "kj4b_qa06ntb_stdv_4b":
product_type_lsb = 0
elif printhead_type == "kj4b_qg06ntt_pt1v":
product_type_lsb = 1
elif printhead_type == "kj4b_yh06wst_stdv":
product_type_lsb = 2
elif printhead_type == "kj4b_1200_008st_wfg1":
product_type_lsb = 3
elif printhead_type == "km1024i_kmdb" or printhead_type == "km1024_kmdb":
product_type_lsb = 0
elif printhead_type == "km1024i_hib" or printhead_type == "km1024_hib":
product_type_lsb = 1
elif printhead_type == "gen5":
product_type_lsb = 0
elif printhead_type == "gen4":
product_type_lsb = 1
elif printhead_type == "xaar_1003_hib" or printhead_type == "xaar_1002_hib":
product_type_lsb = 0
else:
product_type_lsb = -1
if (product_type_msb != -1 and product_type_lsb != -1):
product_type_int = product_type_msb * 2**16 + product_type_lsb * 2**0
print("Product Type : 0x{:08X}".format(product_type_int))
else:
print("Product Type : 0x????????")
# Image Type
if image_type == "user":
print("Image Type : 0x00005355")
elif image_type == "factory":
print("Image Type : 0x00004146")
else:
print("Image Type : 0x0000????")
print("")
In [4]:
gen_product_id("2.0.0", "Ricoh", "User")
gen_system_manager("2.0.0.0", "Ricoh", "Gen5", "User")
In [5]:
gen_product_id("1.0.1", "Ricoh", "User")
gen_system_manager("1.0.1.0", "Ricoh", "Gen4", "User")
In [6]:
gen_product_id("1.1.0", "Kyocera", "User")
gen_system_manager("1.1.0.0", "Kyocera", "KJ4B_QG06NTT_PT1V", "User")
In [7]:
gen_product_id("1.0.0", "Kyocera", "User")
gen_system_manager("1.0.0.0", "Kyocera", "KJ4B_QA06NTB_STDV_4B", "User")
In [8]:
gen_product_id("2.0.3", "Kyocera", "User")
gen_system_manager("2.0.3.1", "Kyocera", "KJ4B_YH06WST_STDV", "User")
In [9]:
gen_product_id("1.0.1", "Kyocera", "User")
gen_system_manager("1.0.1.0", "Kyocera", "KJ4B_1200_008ST_WFG1", "User")
In [10]:
gen_product_id("2.0.0", "KonicaMinolta", "User")
gen_system_manager("2.0.0.0", "KonicaMinolta", "KM1024i_KMDB", "User")
In [11]:
gen_product_id("0.0.0", "KonicaMinolta", "User")
gen_system_manager("1.0.0.0", "KonicaMinolta", "KM1024i_HIB", "User")
In [12]:
gen_product_id("1.0.0", "Xaar", "User")
gen_system_manager("1.0.0.0", "Xaar", "Xaar_1003_HIB", "User")
In [13]:
gen_product_id("1.0.1", "Generic", "Factory")
gen_system_manager("1.0.1.0", "Generic", "Generic", "Factory")
In [16]:
import binascii
def get_product_id(version="000F4628", product_type="4B4D", image_type="5355"):
version_norm = version.lower()
product_type_norm = product_type.lower()
image_type_norm = image_type.lower()
# Calculate Version
version_int = int(version_norm,16)
version_int_string = str(version_int)
# Calculate Product
#product_type_ascii = product_type_norm.decode("hex").lower() # py2
product_type_ascii = product_type_norm.lower()
# Calculate Image
#image_type_ascii = image_type_norm.decode("hex").lower() # py2
image_type_ascii = image_type_norm.lower()
# Print Version
print("Version: {}.{}.{}".format(version_int_string[-9:-6], version_int_string[-6:-3], version_int_string[-3:]))
# Print Product
if product_type_ascii == "ri":
print("Product: Ricoh")
elif product_type_ascii == "km":
print("Product: KonicaMinolta")
elif product_type_ascii == "ky":
print("Product: Kyocera")
elif product_type_ascii == "ge":
print("Product: Generic")
elif product_type_ascii == "xa":
print("Product: Xaar")
else:
print("Product: Unknown")
# Print Image
if image_type_ascii == "su":
print("Image: User")
elif image_type_ascii == "af":
print("Image: Factory")
else:
print("Image: Unknown")
In [17]:
get_product_id("000f4628", "4b59", "5355")