def _set_process_name(self): argc = ctypes.c_int() argv = ctypes.POINTER(ctypes.c_char_p)() ctypes.pythonapi.Py_GetArgcArgv(ctypes.byref(argc), ctypes.byref(argv)) lib_name = utility.get_lib_path() + "/libsgutil.so" libutil = ctypes.cdll.LoadLibrary(lib_name) libutil.spt_init(argc, argv) libutil.setproctitle(self.process)
import os import struct import ctypes from ee.common import logger import ee.common.utility as utility libname = utility.get_lib_path() + "/libsgi2c.so" if libname and os.path.isfile(libname): libi2c = ctypes.cdll.LoadLibrary(libname) else: libi2c = None class CI2cBus(object): def __init__(self, name): self._name = name self._fileno = 0 self._bus = libi2c def __open(self): logger.debug("open i2c device %s" % (self._name)) self._fd = self._bus.sg_i2c_open(self._name) if self._fd <= 0: logger.error("open i2c device %s fail" % (self._name)) return False else: return True def read(self, dev_addr, length): logger.debug("read i2c device %s addr:0x%x length:%d" % (self._name, dev_addr, length))
import zmq import socket import ctypes import threading import traceback from time import clock import time from ee.common import logger import ee.common.utility as utility libdaq = ctypes.cdll.LoadLibrary(utility.get_lib_path() + "/libsgdaq.so") class DataChannel(threading.Thread): def __init__(self, name, port, channelid, sub_filters, data_filters): super(DataChannel, self).__init__() logger.boot( "create %s channel port=%d, id=%d, sub_filters=%r, data_filters=%r" % (name, port, channelid, sub_filters, data_filters)) self._name = name self._port = port self._channelid = channelid self._connector = None self._sub_filters = sub_filters self._data_filters = data_filters self._channel_stop = False self._controller = None self._debug = None def __destruction(self): for sub_filter in self._sub_filters:
import struct import os import ctypes import ee.common.utility as utility from ee.common.ddp_client import DDPClient from ee.common import logger libname = utility.get_lib_path() + "/libsgfpga.so" if libname and os.path.isfile(libname): libaxi4lite = ctypes.cdll.LoadLibrary(libname) else: libaxi4lite = None class Axi4lite(object): def __init__(self, name, register_num): self._name = name self._register_num = register_num self._axi4lite = None def open(self): logger.debug('libsgfpaga path is %s' % (libname)) if libaxi4lite is None: self._axi4lite = RPCAxi4lite(self._name, self._register_num) else: self._axi4lite = CAxi4lite(self._name, self._register_num) return self._axi4lite.open() def read(self, addr, length):
from ctypes import * import platform import re import os from ee.common import utility cmd_so = utility.get_lib_path() + "/libsgcmd.so" libcmd = cdll.LoadLibrary(cmd_so) CONFIG_TERMINAL_COMMANDID_LENGTH = 16 CONFIG_TERMINAL_COMMAND_LENGTH = 64 CONFIG_TERMINAL_CMDPARAMETER_LENGTH = 1024 CONFIG_TERMINAL_REPLY_LENGTH = 4096 CONFIG_TERMINAL_RECV_LENGTH = 2048 class SeTimestamp(Structure): _fields_ = [('SeTimeMiliSecods', c_ushort), ('SeTimeSeconds', c_uint)] class SeCommandCustomField(Structure): _fields_ = [('nOperation', c_int), ('sCommandID', c_char * CONFIG_TERMINAL_COMMANDID_LENGTH), \ ('sCommandKeyword', c_char * CONFIG_TERMINAL_COMMAND_LENGTH), ('sCommandParameters', c_char * CONFIG_TERMINAL_CMDPARAMETER_LENGTH),\ ('sCommandReply', c_char_p), ('nCommandReplyBuffLen', c_short), ('nCommandReplySize', c_short), \ ('tRequestTime', SeTimestamp), ('nStatus', c_int), \ ('nErrorNO', c_int)] class SeNetWorkCustomRecv(Structure): _fields_ = [('nRecvBufferSize', c_ushort), ('iRecvBufferTailCursor', c_int),