#!/usr/bin/env python # Drive a Sony Laserdisc player. # Adam Sampson # FIXME: This should also have a "read from ircat" mode. import sys, serial # All the codes are taken from the LDP-1450 manual, which claims to work for # the LDP-2000/1500/1500P/1550/1550P/1600P/1450/3300P/3600D. Mine's a 3600D. commands = { "audio_mute_on": 0x25, "audio_mute_off": 0x24, "ce": 0x41, # clear entry "ch1_on": 0x46, "ch1_off": 0x47, "ch2_on": 0x48, "ch2_off": 0x49, "chapter_mode": 0x69, "ca": 0x56, # clear all "continue": 0x61, # after still "cx_on": 0x6E, "cx_off": 0x6F, "eject": 0x2A, "eject_enable": 0x74, "eject_disable": 0x75, "enter": 0x40, "f_fast": 0x3B, "r_fast": 0x4B, "f_play": 0x3A, "r_play": 0x4A, "f_scan": 0x3E, "r_scan": 0x4E, "f_slow": 0x3C, "r_slow": 0x4C, "f_step": 0x3D, "r_step": 0x4D, "fwd_relative_search": 0x2D, # not LDP-2000/1550/1550P/1600P "rev_relative_search": 0x2E, # not LDP-2000/1550/1550P/1600P "fwd_step_and_still": 0x2B, "rev_step_and_still": 0x2C, "fwd_track_jump": 0x2D, # LDP-1550/1550P/1600P "rev_track_jump": 0x2E, # LDP-1550/1550P/1600P "frame_mode": 0x55, "index_on": 0x50, "index_off": 0x51, "mark_set": 0x73, "m_search": 0x58, "memory": 0x5A, "menu": 0x42, "motor_off": 0x63, "motor_on": 0x62, "non_cf_play": 0x71, # "disengage color framing" "psc_enable": 0x28, # enable picture stop code "psc_disable": 0x29, "repeat": 0x44, "search": 0x43, "still": 0x4F, "stop": 0x3F, "user_index_control": 0x80, "user_index_on": 0x81, "user_index_off": 0x82, "video_on": 0x27, "video_off": 0x26, "0": 0x30, "1": 0x31, "2": 0x32, "3": 0x33, "4": 0x34, "5": 0x35, "6": 0x36, "7": 0x37, "8": 0x38, "9": 0x39, "addr_inq": 0x60, "chapter_inq": 0x76, "rom_version_inq": 0x72, "status_inq": 0x67, "users_code_inq": 0x79, } responses = { 0x01: "completion", 0x02: "error", 0x03: "lip open", 0x05: "no target", # target not found 0x06: "no frame number", # target number illegal 0x07: "mark return", # mark position has been found 0x0A: "ack", 0x0B: "nak", } def open_player(): return serial.Serial("/dev/ttyS0", 9600, rtscts = 0, dsrdtr = 1) def send_cmd(ser, cmd): if not cmd in commands: print "Unknown command: %s" % cmd sys.exit(1) ser.write(chr(commands[cmd])) code = ord(ser.read(1)) if not code in responses: print "Received unknown response from player: 0x%02X" % code return resp = responses[code] if resp != "ack": print "Got unexpected response from player: %s" % resp if __name__ == "__main__": ser = open_player() for arg in sys.argv[1:]: send_cmd(ser, arg)