Login Page - Create Account

Support Board


Date/Time: Tue, 24 Apr 2018 22:25:47 +0000



Post From: DTC Protocol

[2016-03-24 20:46:31]
Guilherme - Posts: 62
Hi, Petr. DTC binary encoding has nothing to do with the language and types you use. You can implement in in any language. By the way, I'm using Scala for both Server and Client. Here is some code for you to get some idea:


// Encoding request is: 16 0 6 0 7 0 0 0 4 0 0 0 68 84 67 0
// 16 bytes, mensagem tipo 6, DTC version 7, encoding type 4, "DTC/0"
// Encoding response is: 16 0 7 0 7 0 0 0 4 0 0 0 68 84 67 0
def createBinaryEncodingRequest(): ByteString = {
// Hardcoded encoding response expected by SierraChart.
val output = ByteBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN)
output.putShort(16) // message size
output.putShort(DTC_PB.DTCMessageType.ENCODING_REQUEST_VALUE.toShort) //message type: encoding request(equals 6)
output.putInt(protocolVersion)
output.putInt(4) // encoding type 4: requesting Protocol buffer format
output.put('D'.toByte)
output.put('T'.toByte)
output.put('C'.toByte)
output.put(0.toByte)

val o = output.array()
ByteString(o)
}

def createBinaryEncodingResponse(): ByteString = {
// Hardcoded encoding response expected by SierraChart.
val output = ByteBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN)
output.putShort(16) // message size
output.putShort(DTC_PB.DTCMessageType.ENCODING_RESPONSE_VALUE.toShort) //message type: encoding response(equals 7)
output.putInt(protocolVersion)
output.putInt(4) // encoding type 4: tell the client that the server will use Protocol buffer
output.put('D'.toByte)
output.put('T'.toByte)
output.put('C'.toByte)
output.put(0.toByte)

val o = output.array()
ByteString(o)
}
[]s
Guilherme
Date Time Of Last Edit: 2016-03-24 20:49:40