Monstrous amount of changes. Bad commit disciplin.
This commit is contained in:
+8
-3
@@ -159,11 +159,16 @@ function writeBuffer(obj, cmdLength, callback) {
|
||||
*
|
||||
* @param buf buffer
|
||||
* @param str encoding 'ASCII', 'LATIN1' or 'UCS2' or hex values
|
||||
* @param int offset - defaults to 0
|
||||
* @return str in utf8 format
|
||||
*/
|
||||
function decodeMsg(buffer, encoding) {
|
||||
function decodeMsg(buffer, encoding, offset) {
|
||||
var checkEnc;
|
||||
|
||||
if (offset === undefined) {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
for (checkEnc in defs.consts.ENCODING) {
|
||||
if (parseInt(encoding) === defs.consts.ENCODING[checkEnc] || encoding === checkEnc) {
|
||||
encoding = checkEnc;
|
||||
@@ -175,7 +180,7 @@ function decodeMsg(buffer, encoding) {
|
||||
encoding = 'ASCII';
|
||||
}
|
||||
|
||||
return defs.encodings[encoding].decode(buffer);
|
||||
return defs.encodings[encoding].decode(buffer.slice(offset, buffer.length));
|
||||
}
|
||||
|
||||
function encodeMsg(str) {
|
||||
@@ -208,7 +213,7 @@ function pduToObj(pdu, stupidNullByte, callback) {
|
||||
}
|
||||
|
||||
// Returns true if this PDU is a response to another PDU
|
||||
retObj.isResponse = function() {
|
||||
retObj.isResp = function() {
|
||||
return ! ! (this.cmdId & 0x80000000);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user