-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.9.61 PR #801
1.9.61 PR #801
Changes from all commits
744151c
0ce8d93
a28c60c
093b726
1e574bd
6c62ff7
362f288
6d99daf
53a1d8d
a1bd6be
f79e660
be45d4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -58,12 +58,15 @@ function Module() { | |||||||||||||
Osci: 27000000, | ||||||||||||||
Freq: 50 | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
this.Board_Servo = { | ||||||||||||||
Pulse_Min: 150, | ||||||||||||||
Pulse_Max: 600, | ||||||||||||||
us_Min: 400, | ||||||||||||||
us_Max: 2100 | ||||||||||||||
us_Max: 2100, | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
angle: 90 | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
|
||||||||||||||
this.Board_LED_Strip = { | ||||||||||||||
En:0, | ||||||||||||||
sample: 0, | ||||||||||||||
|
@@ -133,7 +136,9 @@ Module.prototype.init = function(handler, config) { | |||||||||||||
this.remoteDataSet[index+6] = (this.Board_Servo.us_Min>>8)&0xff; | ||||||||||||||
|
||||||||||||||
this.remoteDataSet[index+7] = (this.Board_Servo.us_Max)&0xff; | ||||||||||||||
this.remoteDataSet[index+8] = (this.Board_Servo.us_Max>>8)&0xff; | ||||||||||||||
this.remoteDataSet[index+8] = (this.Board_Servo.us_Max>>8)&0xff; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
||||||||||||||
this.remoteDataSet[index+9] = (this.Board_Servo.angle)&0xff; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// led | ||||||||||||||
|
@@ -203,10 +208,14 @@ slave 모드인 경우 duration 속성 간격으로 지속적으로 기기에 | |||||||||||||
Module.prototype.requestLocalData = function() { | ||||||||||||||
var queryString = []; | ||||||||||||||
var data = this.remoteDataSet; // Module 객체의 dataset table read. max length 200 | ||||||||||||||
var checksum = 0; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
for (var index = 0; index < this.avatarBotDataSet; index++) { | ||||||||||||||
var query = (data[index])&0xff; | ||||||||||||||
queryString.push(query); // 1byte | ||||||||||||||
checksum += query; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
} | ||||||||||||||
checksum = (checksum)&0xff; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
queryString.push(checksum); // 1byte | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
/* | ||||||||||||||
for(var i=0; i<(data.length/10); i++) | ||||||||||||||
{ | ||||||||||||||
|
@@ -222,13 +231,20 @@ Module.prototype.requestLocalData = function() { | |||||||||||||
}; | ||||||||||||||
|
||||||||||||||
// 하드웨어에서 온 데이터 처리 | ||||||||||||||
/* | ||||||||||||||
Module.prototype.handleLocalData = function(data) { | ||||||||||||||
var self = this; | ||||||||||||||
for (var i = 0; i < data.length; i++) { | ||||||||||||||
self.dataSet[self.dataSet_index+i] = data[i]; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
console.log('data length ', data.length); | ||||||||||||||
for(var j=0; j<21; j++) | ||||||||||||||
{ | ||||||||||||||
let i = j*10; | ||||||||||||||
console.log('data ',i, ': ', self.dataSet[i], self.dataSet[i+1], self.dataSet[i+2], self.dataSet[i+3], self.dataSet[i+4], self.dataSet[i+5], | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
self.dataSet[i+6], self.dataSet[i+7], self.dataSet[i+8], self.dataSet[i+9]); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if(self.dataSet[0] === 0x99 && self.dataSet[1] === 0x01 && self.dataSet[2] === 0x01 && self.dataSet[3] === self.avatarBotDataSet) | ||||||||||||||
{ | ||||||||||||||
self.dataSet_index = self.dataSet_index + data.length; | ||||||||||||||
|
@@ -250,6 +266,57 @@ Module.prototype.handleLocalData = function(data) { | |||||||||||||
|
||||||||||||||
|
||||||||||||||
}; | ||||||||||||||
*/ | ||||||||||||||
Module.prototype.handleLocalData = function(data) { | ||||||||||||||
var self = this; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
// data.length => 211 | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
var checksum = 0; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
var getChecksum = 0; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
for (var i = 0; i < data.length; i++) { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
if(self.dataSet.length > i) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
{ | ||||||||||||||
self.dataSet[self.dataSet_index+i] = data[i]; | ||||||||||||||
checksum += data[i]; | ||||||||||||||
}else{ | ||||||||||||||
// last buffer | ||||||||||||||
getChecksum = data[i]; | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
checksum = (checksum)&0xff; | ||||||||||||||
|
||||||||||||||
/* | ||||||||||||||
console.log('data length ', data.length, ', checksum = ', checksum, ', getChecksum = ', getChecksum); | ||||||||||||||
for(var j=0; j<21; j++) | ||||||||||||||
{ | ||||||||||||||
let i = j*10; | ||||||||||||||
console.log('data ',i, ': ', self.dataSet[i], self.dataSet[i+1], self.dataSet[i+2], self.dataSet[i+3], self.dataSet[i+4], self.dataSet[i+5], | ||||||||||||||
self.dataSet[i+6], self.dataSet[i+7], self.dataSet[i+8], self.dataSet[i+9]); | ||||||||||||||
} | ||||||||||||||
*/ | ||||||||||||||
|
||||||||||||||
if(self.dataSet[0] === 0x99 && self.dataSet[1] === 0x01 && self.dataSet[2] === 0x01 && self.dataSet[3] === self.avatarBotDataSet && getChecksum == checksum) | ||||||||||||||
{ | ||||||||||||||
self.dataSet_index = self.dataSet_index + (data.length-1); | ||||||||||||||
}else{ | ||||||||||||||
self.dataSet_index = 0; | ||||||||||||||
return; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if(self.dataSet_index == self.avatarBotDataSet){ | ||||||||||||||
self.originParsing(self.dataSet); | ||||||||||||||
self.dataSet_index = 0; | ||||||||||||||
self.dataSet[0] = 0; // clear | ||||||||||||||
self.dataSet[1] = 0; // clear | ||||||||||||||
self.dataSet[2] = 0; // clear | ||||||||||||||
self.dataSet[3] = 0; // clear | ||||||||||||||
// | ||||||||||||||
// console.log('[jhkim] handleLocalData - dataSet_index[11] = ', self.dataSet[11]); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
/* Original Parsing FF 55 ~ */ | ||||||||||||||
Module.prototype.originParsing = function(data) { | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
entry-hw/app/modules/jdcode.js Lines 227 to 264 in be45d4d
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
entry-hw/app/modules/jdcode.js Lines 241 to 261 in be45d4d
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
entry-hw/app/modules/jdcode.js Lines 248 to 260 in be45d4d
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
function Module() { | ||
this.cmdData = [0x26, 0xA8, 0x14, 0x81, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; | ||
this.sensorData = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; | ||
this.dongleData = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; | ||
this.robodog_head = [0x26, 0xA8, 0x14, 0x8A]; | ||
this.rk_cnt = 0; | ||
this.pktCnt = -1; | ||
this.pktLength = 6; | ||
this.ledPacket = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
this.txCnt = 0; | ||
} | ||
|
||
Module.prototype.init = function(handler, config) { | ||
}; | ||
|
||
Module.prototype.requestInitialData = function() { | ||
return null; | ||
}; | ||
|
||
Module.prototype.checkInitialData = function(data, config) { | ||
return true; | ||
}; | ||
|
||
Module.prototype.validateLocalData = function(data) { | ||
return true; | ||
}; | ||
|
||
|
||
|
||
function checksum(cmd){ | ||
let sum = 0; | ||
|
||
cmd.forEach(function (value, idx) { | ||
if(idx > 5) | ||
sum += value; | ||
}); | ||
return sum&0xFF; | ||
} | ||
|
||
|
||
/////////////// 엔트리에서 받은 데이터에 대한 처리 ///////////////////// | ||
Module.prototype.handleRemoteData = function(handler) { | ||
let cmd = handler.read('CMD'); | ||
|
||
if(typeof cmd !== 'object') | ||
return; | ||
|
||
this.cmdData = cmd.slice(); | ||
if(this.cmdData[14] > 0){ | ||
if(this.cmdData[14] == 2){ | ||
this.ledPacket[0] = (this.cmdData[14]&0xC0) | 0x82; | ||
this.ledPacket[1] = this.ledPacket[1] | 0x80; | ||
for(let n=0; n<16; n++) | ||
this.ledPacket[2+n] = this.cmdData[24+n]; | ||
} | ||
if(this.cmdData[14] == 3){ | ||
this.ledPacket[0] = (this.cmdData[14]&0xC0) | 0x83; | ||
this.ledPacket[1] = this.ledPacket[1] | 0x80; | ||
for(let n=0; n<16; n++) | ||
this.ledPacket[2+n] = this.cmdData[24+n]; | ||
} | ||
if(this.cmdData[14] == 4){ | ||
this.ledPacket[1] = (this.cmdData[14]&0xC0) | 0x44; | ||
this.ledPacket[0] = this.ledPacket[0] | 0x40; | ||
for(let n=0; n<16; n++) | ||
this.ledPacket[18+n] = this.cmdData[24+n]; | ||
} | ||
} | ||
else{ | ||
this.ledPacket[0] = 0; | ||
this.ledPacket[1] = 0; | ||
} | ||
}; | ||
|
||
|
||
//////////////// 하드웨어로 보낼 데이터 로직 ///////////// | ||
Module.prototype.requestLocalData = function() { | ||
if(((this.ledPacket[0]&0xC0) == 0xC0) || ((this.ledPacket[1]&0xC0) == 0xC0)){ | ||
if((this.txCnt%2) == 0){ | ||
this.cmdData[14] = this.ledPacket[0]; | ||
for(let n=0; n<16; n++) | ||
this.cmdData[24+n] = this.ledPacket[2+n]; | ||
} | ||
else{ | ||
this.cmdData[14] = this.ledPacket[1]; | ||
for(let n=0; n<16; n++) | ||
this.cmdData[24+n] = this.ledPacket[18+n]; | ||
} | ||
this.cmdData[5] = checksum(this.cmdData); | ||
this.txCnt += 1; | ||
} | ||
return this.cmdData; | ||
}; | ||
|
||
///////////// 하드웨어에서 온 데이터 처리 /////////////////// | ||
Module.prototype.handleLocalData = function(data) { | ||
let sensorData = this.sensorData; | ||
let dongleData = this.dongleData; | ||
let pktLength = this.pktLength; | ||
|
||
let robodog_head = this.robodog_head; | ||
data.forEach(function (value) { | ||
this.rk_cnt = (value==robodog_head[this.rk_cnt])? this.rk_cnt+1 : 0; | ||
if(this.rk_cnt == 4){ | ||
this.rk_cnt = 0; | ||
this.pktCnt = 0; | ||
} | ||
else if(this.pktCnt >= 0){ | ||
if(this.pktCnt == 0) | ||
pktLength = ((value>0) && (value<19))? value-4 : 16; | ||
dongleData[4+this.pktCnt++] = value; | ||
} | ||
|
||
if(this.pktCnt == pktLength){ | ||
this.pktCnt = -1; | ||
var sum = 0; | ||
dongleData.forEach(function (value, idx) { | ||
if(idx > 5) | ||
sum += value; | ||
}); | ||
if(dongleData[5] == (sum&0xFF)){ | ||
dongleData.forEach(function (value, idx) { | ||
sensorData[idx] = value; | ||
}); | ||
} | ||
} | ||
}); | ||
this.pktLength = pktLength; | ||
}; | ||
|
||
function unsingToSign8(data) | ||
{ | ||
return data>127? data-256 : data; | ||
} | ||
function unsingToSign16(data) | ||
{ | ||
return data>32767? data-65536 : data; | ||
} | ||
|
||
///////////// 엔트리로 전달할 데이터 /////////////////////////// | ||
Module.prototype.requestRemoteData = function(handler) { | ||
handler.write("SENSORDATA", this.sensorData); | ||
handler.write('BATTERY', this.sensorData[6]); | ||
handler.write('TOF', this.sensorData[7]); | ||
handler.write('ROLL', unsingToSign8(this.sensorData[8])); | ||
handler.write('PITCH', unsingToSign8(this.sensorData[9])); | ||
handler.write('YAW', unsingToSign16(this.sensorData[10] + this.sensorData[11]*256)); | ||
handler.write('RB0', this.sensorData[12]>127? this.sensorData[12]-256 : this.sensorData[12]); | ||
handler.write('RB1', this.sensorData[13]>127? this.sensorData[13]-256 : this.sensorData[13]); | ||
handler.write('RB2', this.sensorData[14]>127? this.sensorData[14]-256 : this.sensorData[14]); | ||
handler.write('RB3', this.sensorData[15]>127? this.sensorData[15]-256 : this.sensorData[15]); | ||
handler.write('BUTTON', this.sensorData[16]); | ||
handler.write('RB_WATCHDOG', this.sensorData[17]); | ||
handler.write('RB4', this.sensorData[18]>127? this.sensorData[18]-256 : this.sensorData[18]); | ||
handler.write('RB5', this.sensorData[19]>127? this.sensorData[19]-256 : this.sensorData[19]); | ||
}; | ||
|
||
Module.prototype.reset = function() { | ||
this.cmdData = [0x26, 0xA8, 0x14, 0x81, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64]; | ||
this.sensorData = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; | ||
this.ledPacket = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
console.log("reset"); | ||
}; | ||
|
||
module.exports = new Module(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"id": "1D0501", | ||
"name": { | ||
"en": "RoboDog", | ||
"ko": "로보독" | ||
}, | ||
"category": "robot", | ||
"platform": ["win32", "darwin"], | ||
"icon": "robodog.png", | ||
"module": "robodog.js", | ||
"url": "http://www.junilab.co.kr", | ||
"driver": { | ||
"win32-ia32": "JuniLab/dongleSetup.bat", | ||
"win32-x64": "JuniLab/dongleSetup.bat" | ||
}, | ||
"reconnect": true, | ||
"hardware": { | ||
"type": "serial", | ||
"control": "slave", | ||
"duration": 32, | ||
"vendor": "Junilab_Inc", | ||
"pnpId": "0226", | ||
"baudRate": 19200, | ||
"firmwarecheck": false | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.