Page 1 of 5 123 ... LastLast
Results 1 to 10 of 45

Thread: Checksum and Denon 3910

  1. #1
    Join Date
    Aug 2006
    Posts
    152

    Default Checksum and Denon 3910

    Hi
    Have got G4 up and running. Controling my Denon AVC-A11XV. By way of a plugin and GML downloaded.
    Then tried to find one for my Denon 3910 DVD. Nothing found so started to make one for the dvd.

    Have managed to connect to the DVD but not control it.

    Format of the commands is
    Baud 9600
    StopBits 1
    StartBits 1
    Parity Even


    The command requires a checksum to be calculated and added to after ETX

    I manual describes as
    STX = 02
    ETX = 03
    for the power of code ! = 21
    sum = stx + cc+ PCO+PC1..PCn+etx
    =02+21+03
    =26

    I have no idea how to accomplish this in Lua, not even sure if it's correct. It's my very first go at this.

    I have attached the Lau file (most which I have aquired by reading and utilising the denon AVR3805 file I downloaded. So please do not assume I understand Lau programming. It probably a miracle I manged to get it to communicate.

    When I send a command to 3910 then response is 0. If I send again response ie 15 = NAK = over run or framing or parity.

    Hopefully someone can assist.

    regards jolly1

    it's daunting when you realise the enormity of what you don't know:-)
    Attached Files Attached Files

  2. #2
    Join Date
    Aug 2006
    Posts
    152

    Default

    Hi again the checksum should be sent as BCCH high level bit and BCCL low level bit. I'm kinda of gessing her but I take it to mean for 26
    serial.tohexbyte(2)..serial.tohexbyte(6) or similar, but to be honest not that clear on this.

    jolly1

  3. #3
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    Code:
    local ETX = serial.hextobyte('03')
    local STX = serial.hextobyte('02')
    function Checksum(data)
       local ck = ETX  -- include the ETX
       for i = 1, string.len(data) do
           ck = ck + string.byte(data, i)
       end
       ck = math.band(ck, 255)
       return serial.bytetohex(ck)
    end
    And your SendCommand function should look something like this

    Code:
    SendCommand = function(self, cmd)
       serial.Classes.Queued.SendCommand(self, cmd .. ETX.. Checksum(cmd))
    end,
    Note that this assumes that SendStartByte is STX
    --Rob

  4. #4
    Join Date
    Aug 2006
    Posts
    152

    Default

    Rob tried the suggestion, thanks for the reply. I now get an error and the file does not open ?

    also here is my understanding of calculating the checksum
    stx = start of text
    etx = end of text
    cc = command code
    PC1 to Pcn is command code parameters

    Therfore checksum
    checksum = stx + cc + PC1 + PC2 + ..Pcn + etc + etx

    check sum consists of 2 charcters BCCH and BCCL which are entered as individual ASCII codes. So resulting command to send would look something like this

    stx cc pc1 etc etx cksum ascii code cksum ascii code.

    Any help given to getting this running is greatly appreciated

    jolly1

  5. #5
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    Yes, but what's the error you are seeing!?
    --Rob

  6. #6
    Join Date
    Aug 2006
    Posts
    152

    Default

    Rob On starting girder serial error runscript when girder starts.

    jolly1

  7. #7
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    You need to open the Lua console (View menu) and give me more details.
    --Rob

  8. #8
    Join Date
    Aug 2006
    Posts
    152

    Default

    Hi Rob just realised that I could highlight and copy the information.

    Serial Error (RunScript, C:\Program Files\Promixis\Girder\/plugins/serial/dvd3910.lua, 1): C:\Program Files\Promixis\Girder\/plugins/serial/dvd3910.lua:38: unexpected symbol near `local'

  9. #9
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    Ah, I'm guessing that you put the first block of code inside the device definition. Move it before the device definition and you should be fine.
    --Rob

  10. #10
    Join Date
    Aug 2006
    Posts
    152

    Default

    Thanks for the patience but still no joy tried various location with no change
    Hope you folks don't mind but here is a copy of the file pated in I have marked the various locations I tried

    -- First part of calc checksum SEE OTHER LOCATIONS TRIED
    --
    -- local ETX = serial.hextobyte('03')
    -- local STX = serial.hextobyte('02')
    -- function Checksum(data)
    -- local ck = ETX -- include the ETX
    -- for i = 1, string.len(data) do
    -- ck = ck + string.byte(data, i)
    -- end,

    -- ck = math.band(ck, 255)
    -- return serial.bytetohex(ck)
    -- end,


    -- end of First part new calc check sum

    -- <====== Tried it here no joy

    local device = serial.Classes.Queued:New({

    -- <====== Tried it here no joy

    Name = "DVD3910",
    Description = "Denon DVD",

    BaudRate = 9600,
    Parity = 2,
    Sartbits = 0,
    StopBits = 0,
    DataBits = 8,
    FlowControl = 'N',
    IntraCharacterDelay = 0,
    SendStartByte = serial.hextobyte('02'),
    SendTerminator = serial.hextobyte('03'),
    CallbackType = serial.CB_TERMINATED,
    ReceiveTerminator = serial.hextobyte('03'),
    IncompleteResponseTimeout = 200,
    NoResponseTimeout = 200,
    LogLevel = 0,
    GlobalName = 'DVD',

    -- <====== Tried it here no joy

    Settings = {},
    Responses = {},

    -- <====== Tried it here no joy

    Initialize = function (self)
    gir.LogMessage(self.Name, 'Communications OK',3)
    self.Status = "Communication OK"
    return serial.Classes.Queued.Initialize (self)
    end,


    -- <====== Tried it here no joy


    -- Second part of of calc checksum


    -- SendCommand = function(self, cmd)
    -- serial.Classes.Queued.SendCommand(self,cmd,.. ETX.. Checksum(cmd),callback,topofque,force)
    -- end,

    -- End of second part of calc checksum




    -- comment out orginal code
    SendCommand = function (self,command,callback,topofque,force)

    return serial.Classes.Queued.SendCommand (self,command,callback,topofque,force)

    end,



    ReceiveResponse = function ( self, data, code )

    if math.band (code,serial.RXCHAR) and data then
    gir.TriggerEvent ('DVD:'..data,18)

    local cmd = string.sub(data, 1, 2)
    if cmd then
    local func = self.Responses[cmd]
    if func then
    func(self.Settings, data)
    end
    end

    end

    if math.band (code,serial.ERR) then
    gir.LogMessage(self.Name, 'Communcication Error',3)
    end

    if math.band (code, serial.NORESPONSETIMEOUT) > 0 then
    code = serial.zerobits (code,serial.NORESPONSETIMEOUT)
    end -- tells G4 not to report communication errors\timeouts in the Lua Console

    serial.Classes.Queued.ReceiveResponse (self,data,code)

    self.Responses['PW'] = function(Settings, data)
    _, _, self.PowerMain = string.find (data,"PW(.-)$")
    print ("Power:",(self.PowerMain))
    NetRemote.SendLabel ('power', (self.PowerMain))
    end



    end,

    }
    )

    serial.AddDevice (device)

Page 1 of 5 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •