Commit ddf02977 authored by Pieter Van Trappen's avatar Pieter Van Trappen

fmc_eeprom - small improvements and fix to make legacy code run on modern (x64) systems

parent 2f668901
...@@ -3,3 +3,4 @@ ...@@ -3,3 +3,4 @@
*.so *.so
*.a *.a
*.o *.o
*.out
#! /usr/bin/env python #! /usr/bin/env python2
# coding: utf8 # coding: utf8
# Copyright CERN, 2011 # Copyright CERN, 2011
......
#!/usr/bin/python #!/usr/bin/env python2
from ctypes import * from ctypes import cdll, Structure, POINTER, cast, c_int, \
c_char_p, c_void_p, c_ubyte, c_ushort, byref
import array import array
import struct import struct
import os
lib = cdll.LoadLibrary(os.path.dirname(__file__) + "/libipmi/libipmi.so") lib = cdll.LoadLibrary("./libipmi/libipmi.so")
class c_CommonHeader(Structure): class c_CommonHeader(Structure):
_fields_ = [ _fields_ = [
...@@ -331,7 +331,8 @@ def ipmi_get_mfg_date(data): ...@@ -331,7 +331,8 @@ def ipmi_get_mfg_date(data):
def ipmi_get_internal_use_data(data): def ipmi_get_internal_use_data(data):
l = c_int() l = c_int()
d = c_void_p(lib.ipmi_get_internal_use_data(c_char_p(data), byref(l))) lib.ipmi_get_internal_use_data.restype = c_void_p
d = lib.ipmi_get_internal_use_data(c_char_p(data), byref(l))
q = cast(d, POINTER(l.value*c_ubyte)) q = cast(d, POINTER(l.value*c_ubyte))
return q.contents return q.contents
...@@ -366,7 +367,8 @@ def main(): ...@@ -366,7 +367,8 @@ def main():
ipmi_write() ipmi_write()
ipmi_close_file() ipmi_close_file()
test = open('test.out', 'r').read() with open('test.out', 'rb') as testf:
test = testf.read()
print ipmi_get_mfg_date(test) print ipmi_get_mfg_date(test)
d = ipmi_get_internal_use_data(test) d = ipmi_get_internal_use_data(test)
for v in d: for v in d:
......
#! /usr/bin/env python #! /usr/bin/env python2
# coding: utf8 # coding: utf8
# Copyright CERN, 2011 # Copyright CERN, 2011
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
# Last modifications: 16/5/2012 # Last modifications: 16/5/2012
# Import system modules # Import system modules
import sys
import time
import datetime import datetime
import os import os
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment