Shop OBEX P1 Docs P2 Docs Learn Events
BS2, SEROUT, and iPod. Help Needed! — Parallax Forums

BS2, SEROUT, and iPod. Help Needed!

SaltyDaveSaltyDave Posts: 2
edited 2007-10-22 17:59 in BASIC Stamp
I'm trying to use the BS2 to remotely control my ipod via serial communication. I have a dock connector and all the wiring worked out, but the code is giving me issues. I found the ipod's communication protocol here: http://ipodlinux.org/Apple_Accessory_Protocol#iPod_Remote_.28Mode_2.29 but I still can't figure out what my SEROUT command needs to look like. I just want to be able to pause, play, skip forward, skip backward, and change the volume. Can anyone help me figure this out?

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2007-10-22 03:21
    Can you post your code so far?·

    If I read the documentation correctly, the serial communication is a standard 8N1 protocol and the Baud needs to be at least 19.2k.· You should also be using TTL levels to communicate with.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • SaltyDaveSaltyDave Posts: 2
    edited 2007-10-22 16:42
    This is the program I'm using right now to try and figure things out:

    Checksum VAR Byte
    Length VAR Byte
    Mode VAR Byte
    Command1 VAR Byte
    Command2 VAR Byte

    Main:
    Length = $03
    Mode = $00
    Command1 = $01
    Command2 = $02
    GOSUB Serial1

    Length = $03
    Mode = $02
    Command1 = $00
    Command2 = $02
    GOSUB Serial1

    Length = $03
    Mode = $02
    Command1 = $00
    Command2 = $00
    GOSUB Serial1

    PAUSE 1000
    GOTO Main

    Serial1:
    Checksum = $100 - ((Length+Mode+Command1+Command2)+$ff)
    DEBUG "Checksum = ", HEX Checksum, " "
    SEROUT 1, 16416, [noparse][[/noparse]$ff,$55,HEX Length,HEX Mode,HEX Command1,HEX Command2,HEX Checksum]
    RETURN

    From what I understand, this should switch the ipod to remote control mode and turn up the volume every second, but I get no response at all when I run it. I've tried to do some research on the 8n1 standard, but I feel like I'm still missing something there. As for TTL levels, I have no idea what that is. I've also tried using "32" for the baudmode instead of "16416", going by the calculations in the BS2 documentation, but that didn't work either.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2007-10-22 17:59
    You don't need to use the·HEX formatter in the SERIAL·command when sending·data to another device, the HEX formatter is more·for·making·it "Human readable" when using·DEBUG.
    Try this for the SEROUT line...
    ·
    SEROUT 1, 16416, [noparse][[/noparse]$ff,$55,Length,Mode,Command1,Command2,Checksum]··· '.... Inverted
    ·
    SEROUT 1, 32, [noparse][[/noparse]$ff,$55,Length,Mode,Command1,Command2,Checksum]··· '.... Non-Inverted
    ·
    ·
    .... If you’re driving it from a STAMP, then the output is TTL (0V to 5V)· If you are driving it from your PC which you should not be doing without a proper voltage level shifter, the voltages can swing from -12V to 12V
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
Sign In or Register to comment.