示例#1
0
    def read_ctrl(self):
        """
        If the control char device is open and it is readable, then it reads
        the control structure. Every time it internally store the control; it
        will be used as default when no control is provided
        """
        if self.__fdc == None or not self.is_ctrl_readable():
            return None
        # Read the control
        bin_ctrl = os.read(self.__fdc, 512)

        ctrl = ZioCtrl()
        self.lastctrl = ctrl
        ctrl.unpack_to_ctrl(bin_ctrl)
        return ctrl
示例#2
0
 def get_current_ctrl(self):
     """
     It gets the current control. It is only a wrapper of the setCtrl
     method of zCtrl; user can use directly that method
     """
     try:
         fd_num = os.open(self.cur_ctrl, os.O_RDONLY)
         bin_ctrl = os.read(fd_num, 512)
         os.close(fd_num)
     except:
         raise
     else:
         ctrl = ZioCtrl()
         ctrl.unpack_to_ctrl(bin_ctrl)
         return ctrl
示例#3
0
    def read_data(self, ctrl = None, unpack = True):
        """
        If the data char device is open and it is readable, then it reads
        the data
        """
        if self.__fdd == None or not self.is_data_readable():
            return None

        if ctrl == None:
            if self.lastctrl == None:
                print("WARNING: you never read control, only 16 samples read")
                tmpctrl = ZioCtrl()
                tmpctrl.ssize = 1
                tmpctrl.nsamples = 16
            else:
                tmpctrl = self.lastctrl
        else:
            tmpctrl = ctrl

        data_tmp = os.read(self.__fdd, tmpctrl.ssize * tmpctrl.nsamples)
        if unpack:
            return self._unpack_data(data_tmp, tmpctrl.nsamples, tmpctrl.ssize)
        else:
            return data_tmp