diff --git a/interface/audio/python/arm_vsi0.py b/interface/audio/python/arm_vsi0.py index 99029579..23261a76 100644 --- a/interface/audio/python/arm_vsi0.py +++ b/interface/audio/python/arm_vsi0.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Arm Limited. All rights reserved. +# Copyright (c) 2021-2024 Arm Limited. All rights reserved. # Virtual Streaming Interface instance 0 Python script: Audio Input @@ -13,15 +13,18 @@ import logging import wave +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI0: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers @@ -65,26 +68,26 @@ # @param name name of WAVE file to open def openWAVE(name): global WAVE - logging.info("Open WAVE file (read mode): {}".format(name)) + logger.info("Open WAVE file (read mode): {}".format(name)) WAVE = wave.open(name, 'rb') - logging.info(" Number of channels: {}".format(WAVE.getnchannels())) - logging.info(" Sample bits: {}".format(WAVE.getsampwidth() * 8)) - logging.info(" Sample rate: {}".format(WAVE.getframerate())) - logging.info(" Number of frames: {}".format(WAVE.getnframes())) + logger.info(" Number of channels: {}".format(WAVE.getnchannels())) + logger.info(" Sample bits: {}".format(WAVE.getsampwidth() * 8)) + logger.info(" Sample rate: {}".format(WAVE.getframerate())) + logger.info(" Number of frames: {}".format(WAVE.getnframes())) ## Read WAVE frames (global WAVE object) into global AudioFrames object # @param n number of frames to read # @return frames frames read def readWAVE(n): global WAVE - logging.info("Read WAVE frames") + logger.info("Read WAVE frames") frames = WAVE.readframes(n) return frames ## Close WAVE file (global WAVE object) def closeWAVE(): global WAVE - logging.info("Close WAVE file") + logger.info("Close WAVE file") WAVE.close() @@ -92,7 +95,7 @@ def closeWAVE(): # @param block_size size of block to load (in bytes) def loadAudioFrames(block_size): global Data - logging.info("Load audio frames into data buffer") + logger.info("Load audio frames into data buffer") frame_size = CHANNELS * ((SAMPLE_BITS + 7) // 8) frames_max = block_size // frame_size Data = readWAVE(frames_max) @@ -100,17 +103,17 @@ def loadAudioFrames(block_size): ## Initialize def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -120,10 +123,10 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -134,21 +137,21 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value ## Timer event (called at Timer Overflow) def timerEvent(): - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") ## Write DMA registers (the VSI DMA Registers) @@ -157,11 +160,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -171,14 +174,14 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") loadAudioFrames(size) n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -188,10 +191,10 @@ def rdDataDMA(size): # @param size size of data to write (in bytes, multiple of 4) def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) return @@ -202,10 +205,10 @@ def wrCONTROL(value): global CONTROL if ((value ^ CONTROL) & CONTROL_ENABLE_Msk) != 0: if (value & CONTROL_ENABLE_Msk) != 0: - logging.info("Enable Receiver") + logger.info("Enable Receiver") openWAVE('test.wav') else: - logging.info("Disable Receiver") + logger.info("Disable Receiver") closeWAVE() CONTROL = value @@ -214,21 +217,21 @@ def wrCONTROL(value): def wrCHANNELS(value): global CHANNELS CHANNELS = value - logging.info("Number of channels: {}".format(value)) + logger.info("Number of channels: {}".format(value)) ## Write SAMPLE_BITS register (user register) # @param value value to write (32-bit) def wrSAMPLE_BITS(value): global SAMPLE_BITS SAMPLE_BITS = value - logging.info("Sample bits: {}".format(value)) + logger.info("Sample bits: {}".format(value)) ## Write SAMPLE_RATE register (user register) # @param value value to write (32-bit) def wrSAMPLE_RATE(value): global SAMPLE_RATE SAMPLE_RATE = value - logging.info("Sample rate: {}".format(value)) + logger.info("Sample rate: {}".format(value)) ## Read user registers (the VSI User Registers) @@ -236,10 +239,10 @@ def wrSAMPLE_RATE(value): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -250,7 +253,7 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") if index == 0: wrCONTROL(value) @@ -262,7 +265,7 @@ def wrRegs(index, value): wrSAMPLE_RATE(value) Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/audio/python/arm_vsi1.py b/interface/audio/python/arm_vsi1.py index 16432232..075b816e 100644 --- a/interface/audio/python/arm_vsi1.py +++ b/interface/audio/python/arm_vsi1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Arm Limited. All rights reserved. +# Copyright (c) 2021-2024 Arm Limited. All rights reserved. # Virtual Streaming Interface instance 1 Python script: Audio Output @@ -13,15 +13,18 @@ import logging import wave +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI1: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers @@ -65,26 +68,26 @@ # @param name name of WAVE file to open def openWAVE(name): global WAVE - logging.info("Open WAVE file (write mode): {}".format(name)) + logger.info("Open WAVE file (write mode): {}".format(name)) WAVE = wave.open(name, 'wb') WAVE.setnchannels(CHANNELS) WAVE.setsampwidth((SAMPLE_BITS + 7) // 8) WAVE.setframerate(SAMPLE_RATE) - logging.info(" Number of channels: {}".format(CHANNELS)) - logging.info(" Sample bits: {}".format(SAMPLE_BITS)) - logging.info(" Sample rate: {}".format(SAMPLE_RATE)) + logger.info(" Number of channels: {}".format(CHANNELS)) + logger.info(" Sample bits: {}".format(SAMPLE_BITS)) + logger.info(" Sample rate: {}".format(SAMPLE_RATE)) ## Write WAVE frames (global WAVE object) # @param frames frames to write def writeWAVE(frames): global WAVE - logging.info("Write WAVE frames") + logger.info("Write WAVE frames") WAVE.writeframes(frames) ## Close WAVE file (global WAVE object) def closeWAVE(): global WAVE - logging.info("Close WAVE file") + logger.info("Close WAVE file") WAVE.close() @@ -92,23 +95,23 @@ def closeWAVE(): # @param block_size size of block to store (in bytes) def storeAudioFrames(block_size): global Data - logging.info("Store audio frames from data buffer") + logger.info("Store audio frames from data buffer") writeWAVE(Data) ## Initialize def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -118,10 +121,10 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -132,21 +135,21 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value ## Timer event (called at Timer Overflow) def timerEvent(): - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") ## Write DMA registers (the VSI DMA Registers) @@ -155,11 +158,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -169,12 +172,12 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -184,10 +187,10 @@ def rdDataDMA(size): # @param size size of data to write (in bytes, multiple of 4) def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) storeAudioFrames(size) @@ -200,10 +203,10 @@ def wrCONTROL(value): global CONTROL if ((value ^ CONTROL) & CONTROL_ENABLE_Msk) != 0: if (value & CONTROL_ENABLE_Msk) != 0: - logging.info("Enable Transmitter") + logger.info("Enable Transmitter") openWAVE('test.wav') else: - logging.info("Disable Transmitter") + logger.info("Disable Transmitter") closeWAVE() CONTROL = value @@ -212,21 +215,21 @@ def wrCONTROL(value): def wrCHANNELS(value): global CHANNELS CHANNELS = value - logging.info("Number of channels: {}".format(value)) + logger.info("Number of channels: {}".format(value)) ## Write SAMPLE_BITS register (user register) # @param value value to write (32-bit) def wrSAMPLE_BITS(value): global SAMPLE_BITS SAMPLE_BITS = value - logging.info("Sample bits: {}".format(value)) + logger.info("Sample bits: {}".format(value)) ## Write SAMPLE_RATE register (user register) # @param value value to write (32-bit) def wrSAMPLE_RATE(value): global SAMPLE_RATE SAMPLE_RATE = value - logging.info("Sample rate: {}".format(value)) + logger.info("Sample rate: {}".format(value)) ## Read user registers (the VSI User Registers) @@ -234,10 +237,10 @@ def wrSAMPLE_RATE(value): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -248,7 +251,7 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") if index == 0: wrCONTROL(value) @@ -260,7 +263,7 @@ def wrRegs(index, value): wrSAMPLE_RATE(value) Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/python/arm_vio.py b/interface/python/arm_vio.py index eb91f7a5..37d6a424 100644 --- a/interface/python/arm_vio.py +++ b/interface/python/arm_vio.py @@ -12,15 +12,18 @@ import logging +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VIO: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # VIO Signals @@ -34,7 +37,7 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read Signal @@ -42,10 +45,10 @@ def init(): # @return signal signal value read def rdSignal(mask): global SignalIn - logging.info("Python function rdSignal() called") + logger.info("Python function rdSignal() called") signal = SignalIn & mask - logging.debug("Read signal: {}, mask: {}".format(signal, mask)) + logger.debug("Read signal: {}, mask: {}".format(signal, mask)) return signal @@ -56,11 +59,11 @@ def rdSignal(mask): # @return None def wrSignal(mask, signal): global SignalOut - logging.info("Python function wrSignal() called") + logger.info("Python function wrSignal() called") SignalOut &= ~mask SignalOut |= mask & signal - logging.debug("Write signal: {}, mask: {}".format(signal, mask)) + logger.debug("Write signal: {}, mask: {}".format(signal, mask)) return @@ -70,10 +73,10 @@ def wrSignal(mask, signal): # @return value value read (32-bit) def rdValue(index): global Values - logging.info("Python function rdValue() called") + logger.info("Python function rdValue() called") value = Values[index] - logging.debug("Read value at index {}: {}".format(index, value)) + logger.debug("Read value at index {}: {}".format(index, value)) return value @@ -84,10 +87,10 @@ def rdValue(index): # @return None def wrValue(index, value): global Values - logging.info("Python function wrValue() called") + logger.info("Python function wrValue() called") Values[index] = value - logging.debug("Write value at index {}: {}".format(index, value)) + logger.debug("Write value at index {}: {}".format(index, value)) return diff --git a/interface/python/arm_vsi0.py b/interface/python/arm_vsi0.py index 2184eb32..43741a88 100644 --- a/interface/python/arm_vsi0.py +++ b/interface/python/arm_vsi0.py @@ -12,15 +12,18 @@ import logging +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI0: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers @@ -55,17 +58,17 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -75,10 +78,10 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -89,14 +92,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -104,7 +107,7 @@ def wrTimer(index, value): ## Timer event (called at Timer Overflow) # @return None def timerEvent(): - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") ## Write DMA registers (the VSI DMA Registers) @@ -113,11 +116,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -127,12 +130,12 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -143,10 +146,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) return @@ -156,10 +159,10 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -170,10 +173,10 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/python/arm_vsi1.py b/interface/python/arm_vsi1.py index f9db0e24..9f08be22 100644 --- a/interface/python/arm_vsi1.py +++ b/interface/python/arm_vsi1.py @@ -12,15 +12,18 @@ import logging +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI1: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers @@ -55,17 +58,17 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -75,10 +78,10 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -89,14 +92,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -104,7 +107,7 @@ def wrTimer(index, value): ## Timer event (called at Timer Overflow) # @return None def timerEvent(): - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") ## Write DMA registers (the VSI DMA Registers) @@ -113,11 +116,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -127,12 +130,12 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -143,10 +146,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) return @@ -156,10 +159,10 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -170,10 +173,10 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/python/arm_vsi2.py b/interface/python/arm_vsi2.py index d142b544..2a8800d1 100644 --- a/interface/python/arm_vsi2.py +++ b/interface/python/arm_vsi2.py @@ -12,15 +12,18 @@ import logging +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI2: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers @@ -55,17 +58,17 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -75,10 +78,10 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -89,14 +92,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -104,7 +107,7 @@ def wrTimer(index, value): ## Timer event (called at Timer Overflow) # @return None def timerEvent(): - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") ## Write DMA registers (the VSI DMA Registers) @@ -113,11 +116,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -127,12 +130,12 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -143,10 +146,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) return @@ -156,10 +159,10 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -170,10 +173,10 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/python/arm_vsi3.py b/interface/python/arm_vsi3.py index 994162c9..29392bc6 100644 --- a/interface/python/arm_vsi3.py +++ b/interface/python/arm_vsi3.py @@ -12,15 +12,18 @@ import logging +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI3: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers @@ -55,17 +58,17 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -75,10 +78,10 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -89,14 +92,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -104,7 +107,7 @@ def wrTimer(index, value): ## Timer event (called at Timer Overflow) # @return None def timerEvent(): - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") ## Write DMA registers (the VSI DMA Registers) @@ -113,11 +116,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -127,12 +130,12 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -143,10 +146,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) return @@ -156,10 +159,10 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -170,10 +173,10 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/python/arm_vsi4.py b/interface/python/arm_vsi4.py index ff284fc1..36e76b38 100644 --- a/interface/python/arm_vsi4.py +++ b/interface/python/arm_vsi4.py @@ -12,15 +12,18 @@ import logging +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI4: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers @@ -55,17 +58,17 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -75,10 +78,10 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -89,14 +92,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -104,7 +107,7 @@ def wrTimer(index, value): ## Timer event (called at Timer Overflow) # @return None def timerEvent(): - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") ## Write DMA registers (the VSI DMA Registers) @@ -113,11 +116,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -127,12 +130,12 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -143,10 +146,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) return @@ -156,10 +159,10 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -170,10 +173,10 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/python/arm_vsi5.py b/interface/python/arm_vsi5.py index 847e6e56..c003d1d0 100644 --- a/interface/python/arm_vsi5.py +++ b/interface/python/arm_vsi5.py @@ -12,15 +12,18 @@ import logging +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI5: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers @@ -55,17 +58,17 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -75,10 +78,10 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -89,14 +92,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -104,7 +107,7 @@ def wrTimer(index, value): ## Timer event (called at Timer Overflow) # @return None def timerEvent(): - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") ## Write DMA registers (the VSI DMA Registers) @@ -113,11 +116,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -127,12 +130,12 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -143,10 +146,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) return @@ -156,10 +159,10 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -170,10 +173,10 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/python/arm_vsi6.py b/interface/python/arm_vsi6.py index 83447399..0e14a527 100644 --- a/interface/python/arm_vsi6.py +++ b/interface/python/arm_vsi6.py @@ -12,15 +12,18 @@ import logging +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI6: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers @@ -55,17 +58,17 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -75,10 +78,10 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -89,14 +92,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -104,7 +107,7 @@ def wrTimer(index, value): ## Timer event (called at Timer Overflow) # @return None def timerEvent(): - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") ## Write DMA registers (the VSI DMA Registers) @@ -113,11 +116,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -127,12 +130,12 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -143,10 +146,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) return @@ -156,10 +159,10 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -170,10 +173,10 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/python/arm_vsi7.py b/interface/python/arm_vsi7.py index 6c022a30..0880e05b 100644 --- a/interface/python/arm_vsi7.py +++ b/interface/python/arm_vsi7.py @@ -12,15 +12,18 @@ import logging +logger = logging.getLogger(__name__) ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI7: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers @@ -55,17 +58,17 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -75,10 +78,10 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -89,14 +92,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -104,7 +107,7 @@ def wrTimer(index, value): ## Timer event (called at Timer Overflow) # @return None def timerEvent(): - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") ## Write DMA registers (the VSI DMA Registers) @@ -113,11 +116,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -127,12 +130,12 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -143,10 +146,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) return @@ -156,10 +159,10 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -170,10 +173,10 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/sensor/python/arm_vsi2.py b/interface/sensor/python/arm_vsi2.py index 25dd1289..7de4bcf3 100644 --- a/interface/sensor/python/arm_vsi2.py +++ b/interface/sensor/python/arm_vsi2.py @@ -27,16 +27,19 @@ import logging import vsi_sensor +logger = logging.getLogger(__name__) +vsi_sensor.logger = logger ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI2: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) - +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # IRQ registers IRQ_Status = 0 @@ -70,17 +73,17 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") ## Read interrupt request (the VSI IRQ Status Register) # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -90,11 +93,11 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") value = vsi_sensor.wrIRQ(IRQ_Status, value) IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -105,15 +108,15 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: value = vsi_sensor.wrTimerInterval(value) Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -123,7 +126,7 @@ def wrTimer(index, value): def timerEvent(): global IRQ_Status - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") IRQ_Status = vsi_sensor.timerEvent(IRQ_Status) @@ -134,11 +137,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -148,14 +151,14 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") Data = vsi_sensor.rdDataDMA(size) n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -166,10 +169,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) return @@ -179,13 +182,13 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") if index <= vsi_sensor.REG_IDX_MAX: Regs[index] = vsi_sensor.rdRegs(index) value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -196,13 +199,13 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") if index <= vsi_sensor.REG_IDX_MAX: value = vsi_sensor.wrRegs(index, value) Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/sensor/python/vsi_sensor.py b/interface/sensor/python/vsi_sensor.py index 031ca8b7..6dd90beb 100644 --- a/interface/sensor/python/vsi_sensor.py +++ b/interface/sensor/python/vsi_sensor.py @@ -27,6 +27,7 @@ print(f"VSI:Sensor:Exception: {type(e).__name__}") raise +logger = logging.getLogger(__name__) class RecordManager: def __init__(self): @@ -48,7 +49,7 @@ def __init__(self): # Flush variables def flush(self): - logging.info("Flush Record Data") + logger.info("Flush Record Data") self.data_buff = bytearray() self.timestamp = [] self.data_size = [] @@ -63,20 +64,20 @@ def flush(self): # Read one Record from data file and save acquired data in corresponding buffers def __getRecord(self): - logging.info("Get Record Data") + logger.info("Get Record Data") data = readFile(self.HEADER_SIZE) if len(data) == self.HEADER_SIZE: self.timestamp.append(unpack("I", data[:self.TIMESTAMP_SIZE])[0]) self.data_size.append(unpack("I", data[self.TIMESTAMP_SIZE:])[0]) self.data_buff.extend(readFile(self.data_size[-1])) - logging.debug(f"Record Data size: {len(self.data_buff)}") + logger.debug(f"Record Data size: {len(self.data_buff)}") else: - logging.info("No Record") + logger.info("No Record") # Extract requested number of bytes from data buffer # If end of file is reached, return requested number of zeroes def getData(self, size): - logging.info("Get Data from Record") + logger.info("Get Data from Record") if len(self.data_buff) == 0: self.__getRecord() @@ -84,14 +85,14 @@ def getData(self, size): if len(self.data_buff) >= size: data = self.data_buff[:size] self.data_buff = self.data_buff[size:] - logging.debug(f"Requested Data size: {size}") + logger.debug(f"Requested Data size: {size}") if self.active_record_size == 0: self.active_record_size = self.data_size[self.cnt] self.cnt += 1 self.active_record_size -= size else: - logging.info("No Data in Record") + logger.info("No Data in Record") data = bytearray(size) return data @@ -101,7 +102,7 @@ def getData(self, size): def __getWindow(self): window = 0 old_timestamp_num = 0 - logging.info("Get Time window") + logger.info("Get Time window") while True: if len(self.timestamp) == 0: self.__getRecord() @@ -120,11 +121,11 @@ def __getWindow(self): self.__getRecord() self.window = window - logging.debug(f"Window size: {self.window} ms") + logger.debug(f"Window size: {self.window} ms") # Calculate average interval based on number of samples/blocks in current time window def __getInterval(self): - logging.info("Calculate new Interval") + logger.info("Calculate new Interval") if (CONTROL & CONTROL_DMA_Msk) != 0: size = FIFO_SIZE else: @@ -134,7 +135,7 @@ def __getInterval(self): if num > 0: self.interval = round((self.window * 1000)/num) - logging.debug(f"Number of Samples/Blocks: {num}") + logger.debug(f"Number of Samples/Blocks: {num}") # Compensate for time drift record_elapsed_time = (self.timestamp[self.cnt] - self.timestamp[0]) * 1000 @@ -147,7 +148,7 @@ def __getInterval(self): # Calculate new average timer interval when current record timestamp is at least # SLIDE_INTERVAL ahead of last timestamp used for updating the timer def updateTimer(self, interval): - logging.info("Update AVH TimerEvent interval") + logger.info("Update AVH TimerEvent interval") if len(self.timestamp) > self.cnt: time_delta = self.timestamp[self.cnt] - self.timestamp[self.cnt_old] elif len(self.timestamp) == 0: @@ -188,15 +189,15 @@ def __init__(self, buff_size, threshold_size): self.count = 0 def put(self, byte): - logging.info("Put byte in FIFO") + logger.info("Put byte in FIFO") # Check if buffer is already full if self.count == self.buff_size: - logging.info("FIFO is full") + logger.info("FIFO is full") return None else: self.data[self.idx_put] = byte - logging.debug(f"Byte {byte} inserted at position {self.idx_put}") + logger.debug(f"Byte {byte} inserted at position {self.idx_put}") self.idx_put = (self.idx_put + 1) % self.buff_size self.count += 1 if (self.count >= self.threshold_size) and (self.threshold_size != 0): @@ -204,15 +205,15 @@ def put(self, byte): return byte def get(self): - logging.info("Get byte from FIFO") + logger.info("Get byte from FIFO") # Check if buffer is already empty if self.count == 0: - logging.info("FIFO is empty") + logger.info("FIFO is empty") return None else: byte = self.data[self.idx_get] - logging.debug(f"Byte {byte} extracted from position {self.idx_get}") + logger.debug(f"Byte {byte} extracted from position {self.idx_get}") self.idx_get = (self.idx_get + 1) % self.buff_size self.count -= 1 if self.count < self.threshold_size: @@ -260,11 +261,11 @@ def get(self): def openFile(name): global file - logging.info(f"Open recording file (read mode): {name}") + logger.info(f"Open recording file (read mode): {name}") try: file = open(f"{name}", "rb") except Exception as e: - logging.info(f"An error occurred when trying to open recording: {e}") + logger.info(f"An error occurred when trying to open recording: {e}") ## Read data bytes from sensor recording file @@ -274,10 +275,10 @@ def readFile(n_bytes): global file try: - logging.info("Read recording file") + logger.info("Read recording file") data = bytearray(file.read(n_bytes)) except Exception as e: - logging.debug(f"An error occurred when reading n_bytes = {n_bytes}: {e}") + logger.debug(f"An error occurred when reading n_bytes = {n_bytes}: {e}") data = bytearray() return data @@ -288,10 +289,10 @@ def closeFile(): global file try: - logging.info("Close recording file") + logger.info("Close recording file") file.close() except Exception as e: - logging.info(f"An error occurred when closing SDS file: {e}") + logger.info(f"An error occurred when closing SDS file: {e}") ## VSI IRQ Status register @@ -328,15 +329,15 @@ def timerEvent(IRQ_Status): if byte is None: STATUS |= STATUS_OVERFLOW_Msk IRQ_Status |= IRQ_Status_Overflow_Msk - logging.debug("Overflow detected") + logger.debug("Overflow detected") break if FIFO.threshold: IRQ_Status |= IRQ_Status_Threshold_Msk - logging.debug("Threshold event") + logger.debug("Threshold event") else: IRQ_Status |= IRQ_Status_Threshold_Msk - logging.debug("DMA Threshold event") + logger.debug("DMA Threshold event") return IRQ_Status @@ -359,14 +360,14 @@ def wrCONTROL(value): STATUS = 0 Record.flush() if (value & CONTROL_ENABLE_Msk) != 0: - logging.info("Enable Sensor") + logger.info("Enable Sensor") if SENSOR_NAME_VALID: openFile(f"{sensor_filename}.{sensor_idx}.sds") if (value & CONTROL_DMA_Msk) == 0: FIFO = FifoBuff(((FIFO_SIZE // SAMPLE_SIZE) * SAMPLE_SIZE), (DATA_THRESHOLD * SAMPLE_SIZE)) sensor_idx += 1 else: - logging.info("Disable sensor") + logger.info("Disable sensor") if SENSOR_NAME_VALID: closeFile() @@ -389,7 +390,7 @@ def rdSTATUS(): def wrSENSOR_NAME_LEN(value): global SENSOR_NAME_LEN, SENSOR_NAME_VALID, sensor_filename, sensor_name_idx - logging.info("Set new sensor name length and reset filename and valid flag") + logger.info("Set new sensor name length and reset filename and valid flag") sensor_name_idx = 0 sensor_filename = "" SENSOR_NAME_VALID = 0 @@ -402,19 +403,19 @@ def wrSENSOR_NAME_CHAR(value): global SENSOR_NAME_VALID, sensor_filename, sensor_name_idx if sensor_name_idx < SENSOR_NAME_LEN: - logging.info(f"Append {value} to filename") + logger.info(f"Append {value} to filename") sensor_filename += f"{value}" sensor_name_idx += 1 - logging.debug(f"Received {sensor_name_idx} of {SENSOR_NAME_LEN} characters") + logger.debug(f"Received {sensor_name_idx} of {SENSOR_NAME_LEN} characters") if sensor_name_idx == SENSOR_NAME_LEN: - logging.info("Check if file exists and set VALID flag") - logging.debug(f"Filename: {sensor_filename}.{sensor_idx}.sds") + logger.info("Check if file exists and set VALID flag") + logger.debug(f"Filename: {sensor_filename}.{sensor_idx}.sds") if path.isfile(f"{sensor_filename}.{sensor_idx}.sds"): SENSOR_NAME_VALID = 1 else: SENSOR_NAME_VALID = 0 - logging.debug(f"Filename VALID: {SENSOR_NAME_VALID}") + logger.debug(f"Filename VALID: {SENSOR_NAME_VALID}") ## Read SAMPLE_COUNT register (user register) @@ -422,7 +423,7 @@ def wrSENSOR_NAME_CHAR(value): def rdSAMPLE_COUNT(): global SAMPLE_COUNT - logging.debug(f"Fifo Count: {FIFO.count}") + logger.debug(f"Fifo Count: {FIFO.count}") SAMPLE_COUNT = FIFO.count // SAMPLE_SIZE return SAMPLE_COUNT diff --git a/interface/video/python/arm_vsi4.py b/interface/video/python/arm_vsi4.py index 657cdb13..9e30164e 100644 --- a/interface/video/python/arm_vsi4.py +++ b/interface/video/python/arm_vsi4.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Arm Limited. All rights reserved. +# Copyright (c) 2021-2024 Arm Limited. All rights reserved. # Virtual Streaming Interface instance 4 Python script @@ -13,14 +13,19 @@ import logging import vsi_video +logger = logging.getLogger(__name__) +vsi_video.logger = logger + ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI4: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # Video Server configuration @@ -60,7 +65,7 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") vsi_video.init(server_address, server_authkey) @@ -68,10 +73,10 @@ def init(): # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -81,11 +86,11 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") value = vsi_video.wrIRQ(IRQ_Status, value) IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -96,14 +101,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -113,7 +118,7 @@ def wrTimer(index, value): def timerEvent(): global IRQ_Status - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") IRQ_Status = vsi_video.timerEvent(IRQ_Status) @@ -124,11 +129,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -138,14 +143,14 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") Data = vsi_video.rdDataDMA(size) n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -156,10 +161,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) vsi_video.wrDataDMA(data, size) @@ -171,13 +176,13 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") if index <= vsi_video.REG_IDX_MAX: Regs[index] = vsi_video.rdRegs(index) value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -188,13 +193,13 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") if index <= vsi_video.REG_IDX_MAX: value = vsi_video.wrRegs(index, value) Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/video/python/arm_vsi5.py b/interface/video/python/arm_vsi5.py index d3469c19..9f2f5260 100644 --- a/interface/video/python/arm_vsi5.py +++ b/interface/video/python/arm_vsi5.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Arm Limited. All rights reserved. +# Copyright (c) 2021-2024 Arm Limited. All rights reserved. # Virtual Streaming Interface instance 5 Python script @@ -13,14 +13,19 @@ import logging import vsi_video +logger = logging.getLogger(__name__) +vsi_video.logger = logger + ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI5: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # Video Server configuration @@ -60,7 +65,7 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") vsi_video.init(server_address, server_authkey) @@ -68,10 +73,10 @@ def init(): # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -81,11 +86,11 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") value = vsi_video.wrIRQ(IRQ_Status, value) IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -96,14 +101,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -113,7 +118,7 @@ def wrTimer(index, value): def timerEvent(): global IRQ_Status - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") IRQ_Status = vsi_video.timerEvent(IRQ_Status) @@ -124,11 +129,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -138,14 +143,14 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") Data = vsi_video.rdDataDMA(size) n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -156,10 +161,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) vsi_video.wrDataDMA(data, size) @@ -171,13 +176,13 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") if index <= vsi_video.REG_IDX_MAX: Regs[index] = vsi_video.rdRegs(index) value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -188,13 +193,13 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") if index <= vsi_video.REG_IDX_MAX: value = vsi_video.wrRegs(index, value) Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/video/python/arm_vsi6.py b/interface/video/python/arm_vsi6.py index 718616ea..94a9b524 100644 --- a/interface/video/python/arm_vsi6.py +++ b/interface/video/python/arm_vsi6.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Arm Limited. All rights reserved. +# Copyright (c) 2021-2024 Arm Limited. All rights reserved. # Virtual Streaming Interface instance 6 Python script @@ -13,14 +13,19 @@ import logging import vsi_video +logger = logging.getLogger(__name__) +vsi_video.logger = logger + ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI6: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # Video Server configuration @@ -60,7 +65,7 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") vsi_video.init(server_address, server_authkey) @@ -68,10 +73,10 @@ def init(): # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -81,11 +86,11 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") value = vsi_video.wrIRQ(IRQ_Status, value) IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -96,14 +101,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -113,7 +118,7 @@ def wrTimer(index, value): def timerEvent(): global IRQ_Status - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") IRQ_Status = vsi_video.timerEvent(IRQ_Status) @@ -124,11 +129,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -138,14 +143,14 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") Data = vsi_video.rdDataDMA(size) n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -156,10 +161,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) vsi_video.wrDataDMA(data, size) @@ -171,13 +176,13 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") if index <= vsi_video.REG_IDX_MAX: Regs[index] = vsi_video.rdRegs(index) value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -188,13 +193,13 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") if index <= vsi_video.REG_IDX_MAX: value = vsi_video.wrRegs(index, value) Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/video/python/arm_vsi7.py b/interface/video/python/arm_vsi7.py index 6899a207..b76a83a1 100644 --- a/interface/video/python/arm_vsi7.py +++ b/interface/video/python/arm_vsi7.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Arm Limited. All rights reserved. +# Copyright (c) 2021-2024 Arm Limited. All rights reserved. # Virtual Streaming Interface instance 7 Python script @@ -13,14 +13,19 @@ import logging import vsi_video +logger = logging.getLogger(__name__) +vsi_video.logger = logger + ## Set verbosity level #verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } -logging.basicConfig(format='Py: VSI7: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity) +logger.info("Verbosity level is set to " + level[verbosity]) # Video Server configuration @@ -60,7 +65,7 @@ ## Initialize # @return None def init(): - logging.info("Python function init() called") + logger.info("Python function init() called") vsi_video.init(server_address, server_authkey) @@ -68,10 +73,10 @@ def init(): # @return value value read (32-bit) def rdIRQ(): global IRQ_Status - logging.info("Python function rdIRQ() called") + logger.info("Python function rdIRQ() called") value = IRQ_Status - logging.debug("Read interrupt request: {}".format(value)) + logger.debug("Read interrupt request: {}".format(value)) return value @@ -81,11 +86,11 @@ def rdIRQ(): # @return value value written (32-bit) def wrIRQ(value): global IRQ_Status - logging.info("Python function wrIRQ() called") + logger.info("Python function wrIRQ() called") value = vsi_video.wrIRQ(IRQ_Status, value) IRQ_Status = value - logging.debug("Write interrupt request: {}".format(value)) + logger.debug("Write interrupt request: {}".format(value)) return value @@ -96,14 +101,14 @@ def wrIRQ(value): # @return value value written (32-bit) def wrTimer(index, value): global Timer_Control, Timer_Interval - logging.info("Python function wrTimer() called") + logger.info("Python function wrTimer() called") if index == 0: Timer_Control = value - logging.debug("Write Timer_Control: {}".format(value)) + logger.debug("Write Timer_Control: {}".format(value)) elif index == 1: Timer_Interval = value - logging.debug("Write Timer_Interval: {}".format(value)) + logger.debug("Write Timer_Interval: {}".format(value)) return value @@ -113,7 +118,7 @@ def wrTimer(index, value): def timerEvent(): global IRQ_Status - logging.info("Python function timerEvent() called") + logger.info("Python function timerEvent() called") IRQ_Status = vsi_video.timerEvent(IRQ_Status) @@ -124,11 +129,11 @@ def timerEvent(): # @return value value written (32-bit) def wrDMA(index, value): global DMA_Control - logging.info("Python function wrDMA() called") + logger.info("Python function wrDMA() called") if index == 0: DMA_Control = value - logging.debug("Write DMA_Control: {}".format(value)) + logger.debug("Write DMA_Control: {}".format(value)) return value @@ -138,14 +143,14 @@ def wrDMA(index, value): # @return data data read (bytearray) def rdDataDMA(size): global Data - logging.info("Python function rdDataDMA() called") + logger.info("Python function rdDataDMA() called") Data = vsi_video.rdDataDMA(size) n = min(len(Data), size) data = bytearray(size) data[0:n] = Data[0:n] - logging.debug("Read data ({} bytes)".format(size)) + logger.debug("Read data ({} bytes)".format(size)) return data @@ -156,10 +161,10 @@ def rdDataDMA(size): # @return None def wrDataDMA(data, size): global Data - logging.info("Python function wrDataDMA() called") + logger.info("Python function wrDataDMA() called") Data = data - logging.debug("Write data ({} bytes)".format(size)) + logger.debug("Write data ({} bytes)".format(size)) vsi_video.wrDataDMA(data, size) @@ -171,13 +176,13 @@ def wrDataDMA(data, size): # @return value value read (32-bit) def rdRegs(index): global Regs - logging.info("Python function rdRegs() called") + logger.info("Python function rdRegs() called") if index <= vsi_video.REG_IDX_MAX: Regs[index] = vsi_video.rdRegs(index) value = Regs[index] - logging.debug("Read user register at index {}: {}".format(index, value)) + logger.debug("Read user register at index {}: {}".format(index, value)) return value @@ -188,13 +193,13 @@ def rdRegs(index): # @return value value written (32-bit) def wrRegs(index, value): global Regs - logging.info("Python function wrRegs() called") + logger.info("Python function wrRegs() called") if index <= vsi_video.REG_IDX_MAX: value = vsi_video.wrRegs(index, value) Regs[index] = value - logging.debug("Write user register at index {}: {}".format(index, value)) + logger.debug("Write user register at index {}: {}".format(index, value)) return value diff --git a/interface/video/python/vsi_video.py b/interface/video/python/vsi_video.py index 8a7c6db8..f19f22c3 100644 --- a/interface/video/python/vsi_video.py +++ b/interface/video/python/vsi_video.py @@ -31,6 +31,7 @@ print(f"VSI:Video:Exception: {type(e).__name__}") raise +logger = logging.getLogger(__name__) class VideoClient: def __init__(self): @@ -105,7 +106,7 @@ def closeServer(self): self.conn.send([self.CLOSE_SERVER]) self.conn.close() except Exception as e: - logging.error(f'Exception occurred on cleanup: {e}') + logger.error(f'Exception occurred on cleanup: {e}') # User registers @@ -166,7 +167,7 @@ def init(address, authkey): base_dir = path.dirname(__file__) server_path = path.join(base_dir, 'vsi_video_server.py') - logging.info("Start video server") + logger.info("Start video server") if path.isfile(server_path): # Start Video Server if os_name == 'nt': @@ -181,10 +182,10 @@ def init(address, authkey): # Connect to Video Server Video.connectToServer(address, authkey) if Video.conn == None: - logging.error("Server not connected") + logger.error("Server not connected") else: - logging.error(f"Server script not found: {server_path}") + logger.error(f"Server script not found: {server_path}") # Register clean-up function atexit.register(cleanup) @@ -289,29 +290,29 @@ def wrCONTROL(value): if ((value ^ CONTROL) & CONTROL_ENABLE_Msk) != 0: STATUS &= ~STATUS_ACTIVE_Msk if (value & CONTROL_ENABLE_Msk) != 0: - logging.info("Start video stream") + logger.info("Start video stream") if Video.conn != None: - logging.info("Configure video stream") + logger.info("Configure video stream") configuration_valid = Video.configureStream(FRAME_WIDTH, FRAME_HEIGHT, COLOR_FORMAT, FRAME_RATE) if configuration_valid: - logging.info("Enable video stream") + logger.info("Enable video stream") server_active = Video.enableStream(MODE) if server_active: STATUS |= STATUS_ACTIVE_Msk STATUS &= ~(STATUS_OVERFLOW_Msk | STATUS_UNDERFLOW_Msk | STATUS_EOS_Msk) else: - logging.error("Enable video stream failed") + logger.error("Enable video stream failed") else: - logging.error("Configure video stream failed") + logger.error("Configure video stream failed") else: - logging.error("Server not connected") + logger.error("Server not connected") else: - logging.info("Stop video stream") + logger.info("Stop video stream") if Video.conn != None: - logging.info("Disable video stream") + logger.info("Disable video stream") Video.disableStream() else: - logging.error("Server not connected") + logger.error("Server not connected") if (value & CONTROL_BUF_FLUSH_Msk) != 0: value &= ~CONTROL_BUF_FLUSH_Msk @@ -336,7 +337,7 @@ def rdSTATUS(): def wrFILENAME_LEN(value): global STATUS, FILENAME_LEN, FILENAME_VALID, Filename, FilenameIdx - logging.info("Set new source name length and reset filename and valid flag") + logger.info("Set new source name length and reset filename and valid flag") FilenameIdx = 0 Filename = "" FILENAME_VALID = 0 @@ -349,21 +350,21 @@ def wrFILENAME_CHAR(value): global FILENAME_VALID, Filename, FilenameIdx if FilenameIdx < FILENAME_LEN: - logging.info(f"Append {value} to filename") + logger.info(f"Append {value} to filename") Filename += f"{value}" FilenameIdx += 1 - logging.debug(f"Received {FilenameIdx} of {FILENAME_LEN} characters") + logger.debug(f"Received {FilenameIdx} of {FILENAME_LEN} characters") if FilenameIdx == FILENAME_LEN: - logging.info("Check if file exists on Server side and set VALID flag") - logging.debug(f"Filename: {Filename}") + logger.info("Check if file exists on Server side and set VALID flag") + logger.debug(f"Filename: {Filename}") if Video.conn != None: FILENAME_VALID = Video.setFilename(Filename, MODE) else: - logging.error("Server not connected") + logger.error("Server not connected") - logging.debug(f"Filename VALID: {FILENAME_VALID}") + logger.debug(f"Filename VALID: {FILENAME_VALID}") ## Write FRAME_INDEX register (user register) diff --git a/interface/video/python/vsi_video_server.py b/interface/video/python/vsi_video_server.py index 831179c9..51c4f1d4 100644 --- a/interface/video/python/vsi_video_server.py +++ b/interface/video/python/vsi_video_server.py @@ -30,14 +30,18 @@ except Exception as e: print(f"VSI:Video:Server:Exception: {type(e).__name__}") +logger = logging.getLogger(__name__) ## Set verbosity level +#verbosity = logging.DEBUG +#verbosity = logging.INFO +#verbosity = logging.WARNING verbosity = logging.ERROR # [debugging] Verbosity settings level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" } logging.basicConfig(format='VSI Server: [%(levelname)s]\t%(message)s', level = verbosity) -logging.info("Verbosity level is set to " + level[verbosity]) +logger.info("Verbosity level is set to " + level[verbosity]) # Default Server configuration default_address = ('127.0.0.1', 6000) @@ -104,7 +108,7 @@ def _setFilename(self, base_dir, filename, mode): self.video = False file_path = os.path.join(base_dir, filename) - logging.debug(f"File path: {file_path}") + logger.debug(f"File path: {file_path}") if (mode & MODE_IO_Msk) == MODE_Input: self.mode = MODE_Input @@ -160,7 +164,7 @@ def _enableStream(self, mode): if self.filename == "": self.stream = cv2.VideoCapture(0) if not self.stream.isOpened(): - logging.error("Failed to open Camera interface") + logger.error("Failed to open Camera interface") return else: self.stream = cv2.VideoCapture(self.filename) @@ -168,7 +172,7 @@ def _enableStream(self, mode): video_fps = self.stream.get(cv2.CAP_PROP_FPS) if video_fps > self.frame_rate: self.frame_ratio = video_fps / self.frame_rate - logging.debug(f"Frame ratio: {self.frame_ratio}") + logger.debug(f"Frame ratio: {self.frame_ratio}") else: if self.filename != "": extension = str(self.filename).split('.')[-1].lower() @@ -197,7 +201,7 @@ def _enableStream(self, mode): self.stream = cv2.VideoWriter(self.filename, fourcc, self.frame_rate, self.resolution) self.active = True - logging.info("Stream enabled") + logger.info("Stream enabled") # Disable Video Server def _disableStream(self): @@ -207,7 +211,7 @@ def _disableStream(self): self.frame_index = self.stream.get(cv2.CAP_PROP_POS_FRAMES) self.stream.release() self.stream = None - logging.info("Stream disabled") + logger.info("Stream disabled") # Resize frame to requested resolution in pixels def __resizeFrame(self, frame, resolution): @@ -239,13 +243,13 @@ def __resizeFrame(self, frame, resolution): top = (frame_h - crop_h) // 2 bottom = top + crop_h frame = frame[top : bottom, left : right] - logging.debug(f"Frame cropped from ({frame_w}, {frame_h}) to ({frame.shape[1]}, {frame.shape[0]})") + logger.debug(f"Frame cropped from ({frame_w}, {frame_h}) to ({frame.shape[1]}, {frame.shape[0]})") - logging.debug(f"Resize frame from ({frame.shape[1]}, {frame.shape[0]}) to ({resolution[0]}, {resolution[1]})") + logger.debug(f"Resize frame from ({frame.shape[1]}, {frame.shape[0]}) to ({resolution[0]}, {resolution[1]})") try: frame = cv2.resize(frame, resolution) except Exception as e: - logging.error(f"Error in resizeFrame(): {e}") + logger.error(f"Error in resizeFrame(): {e}") return frame @@ -285,11 +289,11 @@ def __changeColorSpace(self, frame, color_space): color_format = cv2.COLOR_YUV2BGR_I420 if color_format != None: - logging.debug(f"Change color space to {color_format}") + logger.debug(f"Change color space to {color_format}") try: frame = cv2.cvtColor(frame, color_format) except Exception as e: - logging.error(f"Error in changeColorSpace(): {e}") + logger.error(f"Error in changeColorSpace(): {e}") return frame @@ -308,22 +312,22 @@ def _readFrame(self): _, tmp_frame = self.stream.read() self.frame_drop += (self.frame_ratio - 1) if self.frame_drop > 1: - logging.debug(f"Frames to drop: {self.frame_drop}") + logger.debug(f"Frames to drop: {self.frame_drop}") drop = int(self.frame_drop // 1) for i in range(drop): _, _ = self.stream.read() - logging.debug(f"Frames dropped: {drop}") + logger.debug(f"Frames dropped: {drop}") self.frame_drop -= drop - logging.debug(f"Frames left to drop: {self.frame_drop}") + logger.debug(f"Frames left to drop: {self.frame_drop}") else: _, tmp_frame = self.stream.read() if tmp_frame is None: self.eos = True - logging.debug("End of stream.") + logger.debug("End of stream.") else: tmp_frame = cv2.imread(self.filename) self.eos = True - logging.debug("End of stream.") + logger.debug("End of stream.") if tmp_frame is not None: tmp_frame = self.__resizeFrame(tmp_frame, self.resolution) @@ -356,13 +360,13 @@ def _writeFrame(self, frame): # Run Video Server def run(self): - logging.info("Video server started") + logger.info("Video server started") try: conn = self.listener.accept() - logging.info(f'Connection accepted {self.listener.address}') + logger.info(f'Connection accepted {self.listener.address}') except Exception: - logging.error("Connection not accepted") + logger.error("Connection not accepted") return while True: @@ -375,38 +379,38 @@ def run(self): payload = recv[1:] # Payload if cmd == self.SET_FILENAME: - logging.info("Set filename called") + logger.info("Set filename called") filename_valid = self._setFilename(payload[0], payload[1], payload[2]) conn.send(filename_valid) elif cmd == self.STREAM_CONFIGURE: - logging.info("Stream configure called") + logger.info("Stream configure called") configuration_valid = self._configureStream(payload[0], payload[1], payload[2], payload[3]) conn.send(configuration_valid) elif cmd == self.STREAM_ENABLE: - logging.info("Enable stream called") + logger.info("Enable stream called") self._enableStream(payload[0]) conn.send(self.active) elif cmd == self.STREAM_DISABLE: - logging.info("Disable stream called") + logger.info("Disable stream called") self._disableStream() conn.send(self.active) elif cmd == self.FRAME_READ: - logging.info("Read frame called") + logger.info("Read frame called") frame = self._readFrame() conn.send_bytes(frame) conn.send(self.eos) elif cmd == self.FRAME_WRITE: - logging.info("Write frame called") + logger.info("Write frame called") frame = conn.recv_bytes() self._writeFrame(frame) elif cmd == self.CLOSE_SERVER: - logging.info("Close server connection") + logger.info("Close server connection") self.stop() # Stop Video Server @@ -418,7 +422,7 @@ def stop(self): except Exception: pass self.listener.close() - logging.info("Video server stopped") + logger.info("Video server stopped") # Validate IP address