Skip to content

ReadMusicEnd() reports bad value #6

Description

@PSLLSP

Function Ed.ReadMusicEnd() report wrong status and it can end with deadlock condition.

There are two constants defined related to ReadMusicEnd():

    "Ed.MUSIC_FINISHED":     0x01,
    "Ed.MUSIC_NOT_FINISHED": 0x00,

Function ReadMusicEnd() should first test if any music is played at all and if not, return 1 (MUSIC_FINISHED); or other value. Current implementation in that case returns 0 (MUSIC_NOT_FINISHED).

Demo, it ends in deadlock condition after first pass of the loop:

#-------------Setup----------------

import Ed

Ed.EdisonVersion = Ed.V2

Ed.DistanceUnits = Ed.CM
Ed.Tempo = Ed.TEMPO_MEDIUM

#--------Your code below-----------

led = False
Ed.PlayBeep()
while True:
    while Ed.ReadMusicEnd() == Ed.MUSIC_NOT_FINISHED: pass  # bug is here
    led = not led
    if led:
        Ed.LeftLed(Ed.ON)
        Ed.RightLed(Ed.OFF)
    else:
        Ed.LeftLed(Ed.OFF)
        Ed.RightLed(Ed.ON)
    Ed.TimeWait(50, Ed.TIME_MILLISECONDS)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions