Shop OBEX P1 Docs P2 Docs Learn Events
multicore conflict happened in using microSD card and fdserial — Parallax Forums

multicore conflict happened in using microSD card and fdserial

KevinKKKevinKK Posts: 27
edited 2014-09-01 15:37 in Propeller 1
I try to make a project that ActiviryBot can navigate/avoid with a mounted turning Ping))) sensor , play music from microSD card and communicate with Bluetooth. I try to use three additional cogs, however, the playing microSD card cog and bluetooth communication cog just can't run correctly in the same program. When I block either of the two cogs, the problem will not happen.
Does anyone can tell me that the two cogs can't open it simultaneously ?
IMAG0033.jpg
mult.c
1024 x 1827 - 144K
c
c
3K

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2014-09-01 15:29
    I think you're trying to access the microSD card routines from two separate cogs at the same time.

    You call SD_mount from the main program and wav_play as well. You're also starting up a separate cog with play_sound which also calls sd_mount and wav_play. You can't do that. You can use locks (semaphores) to prevent both cogs from accessing sd_mount and wav_play at the same time.

    In bt_control, you're using global variable c. As long as you don't use c from another cog, you should be ok. It's better to either use local variables or make up a unique name like bt_control_c that's harder to accidentally use from more than one cog.
  • ElectrodudeElectrodude Posts: 1,658
    edited 2014-09-01 15:37
    I only found the SD card being used in one place. However, you're definitely running out of cogs.

    Here's how your using your cogs:
    cog 0: main
    cog 1: fdserial
    cog 2: play_sound
    cog 3: turn_table
    cog 4: bt_control
    cog 5: sd driver
    cog 6: wav_play streamer
    cog 7: wav_play audio output

    nonexistent cog 8: servos which don't run because there are no more cogs for it

    EDIT: wav_play does sd_mount, but sd_mount is probably smart enough not to have two SD drivers, so this probably doesn't matter.

    Stopping any other cog will let the servos get a cog, which is why the servos only work if you comment out the SD or bluetooth cogs starts.


    Also, you should probably get rid of the curly braces on this line:
    const char techloop[] = {"crazy.wav"};
    
    The prototypes don't agree. You're putting an array of arrays of chars (an array of strings) into an array of chars (a string). I'm surprised that line compiles.

    EDIT: The prototypes do agree. It's an array of arrays, not an array of pointers to arrays. It will still be less confusing if you get rid of the curly braces.
Sign In or Register to comment.