Skip to content

Commit

Permalink
Merge pull request #142 from pjzander-signify/issue_141
Browse files Browse the repository at this point in the history
Add support for big endian in function endpoint_attribute_list (#141)
  • Loading branch information
tecimovic authored May 7, 2021
2 parents 5d33b8b + 5139037 commit e3a60c2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src-electron/generator/helper-endpointconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ function endpoint_attribute_count(options) {
function endpoint_attribute_list(options) {
let comment = null

let littleEndian = true
let pointerSize = 4
if (options.hash.endian == 'big') {
littleEndian = false
if (typeof options.hash.pointer != 'undefined') {
pointerSize = options.hash.pointer
}
}

let ret = '{ \\\n'
this.attributeList.forEach((at) => {
if (at.comment != comment) {
Expand All @@ -267,7 +276,11 @@ function endpoint_attribute_list(options) {
} else if (at.isMacro) {
finalDefaultValue = at.defaultValue
} else {
finalDefaultValue = `ZAP_SIMPLE_DEFAULT(${at.defaultValue})`
let defaultValue = at.defaultValue
if (!littleEndian) {
defaultValue = Number(defaultValue).toString(16).padStart(6,'0x0000').padEnd(2+2*pointerSize,'0')
}
finalDefaultValue = `ZAP_SIMPLE_DEFAULT(${defaultValue})`
}
ret += ` { ${at.id}, ${at.type}, ${at.size}, ${mask}, ${finalDefaultValue} }, /* ${at.name} */ \\\n`
})
Expand Down

0 comments on commit e3a60c2

Please sign in to comment.