python分段错误,如果为真:

2024-04-25 06:56:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用推荐的adafruit库(github)如所述here在我的raspberry pi上使用python运行neopix。 这是我正在执行的代码,直到CLC_RUNNING和CLC_STOP都是0,当我把它们切换到1时,我得到了分段错误,代码的结构有什么错误吗?我能找出问题的原因吗?!在

if __name__ == '__main__':

    # Create NeoPixel object with appropriate configuration.
    strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL, LED_STRIP)
    # Intialize the library (must be called once before other functions).
    strip.begin()

    # Startsequence show for 5 seconds
    showSplashScreen(strip)

    # read Config File
    readConfigFile()

    print ('Press Ctrl-C to quit.')

    run = True

    while run:

        # get current time from system
        now = datetime.datetime.now()

        # get current minute and second Value for color within hour
        currTimeValue = now.second + (now.minute * 60)

        # 3600 iterations per hour over Rainbow colors
        for j in range(currTimeValue, 3600):

            # if both are 1 i will get the segmentation fault
            if CLC_RUNNING == 1 and CLC_STOP == 1:
               break

            if j%10 == 0:
                readConfigFile()

            h = j / 3600.0  # every hue devided into 3600 steps

            binaryTime(strip, h)

            time.sleep(1)   #sleep for 1 second

Tags: the代码forgetledif错误running