-
Notifications
You must be signed in to change notification settings - Fork 117
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
Question: The "others" event callback #2
Comments
About others
The way I handle this issue is problematic and buggy. It broke the protocol: Send and reply( I am checking this project https://github.com/kliment/Printrun, They sent GCode with checksum to verify integrity of data, so I guess data lost is possible. But I am little worry about this issue. More About GCode sender
I feel sorry that I told you that I am busy with other staff so that I can't contribute back again and again. I think I can make it right in two weeks(at most 3 weeks). And migrate it base at your branch to contribute back. Let me know what you think. Bests, |
Thank you for the information. I'm currently working on Marlin firmware support using the Snapmaker. For the issue you mentioned above, I may have to hold program execution when receiving M109, M190, or similar commands that will take long time to execute. I will get back to you when I found the solution. https://github.com/cncjs/cncjs/blob/master/src/app/controllers/Marlin/MarlinController.js |
Documentation
According to the documentation, both M190 and M109 will wait for the temperature to be reached before proceeding with the next command. If users do not want to pause for heating, they have to use M140 and M104 instead. In CNCjs 1.9.11 (https://github.com/cncjs/cncjs/releases/tag/v1.9.11), I added a new feature that can handle M0, M1, M2, M30, and M6 tool change commands, and pause program execution. The web UI will show a notification message or a modal window asking user to continue: https://github.com/cncjs/cncjs/blob/master/src/app/controllers/Marlin/MarlinController.js#L345-L369 For M109 and M190 commands, I can use the same mechanism to pause program execution, and show a modal window to display a temperature chart with current temperature. During the waiting period, user can force stopping with M112, or wait until the target temperature has reached. That's what I may want to do next. Please let me know if I missed anything. |
There is one thing I need to clarify. The G20 (inch units) command does not work as expected when I execute the following:
Actually, it moved by 1mm, not 1 inch. The behavior seems incorrect according to the documentation: http://marlinfw.org/docs/gcode/G020.html |
M109 and M190 will block execution if temperature is not set by the |
Hi @whimsycwd From my test result, Marlin will respond an "ok" until the target temperature is reached, as shown below: Set heated bed temperature
Set extruder temperature
I think it won't break the send-response protocol if we only care about the "ok" response. Also, the query position timer should be disabled during the period of waiting for temperature with M109 or M190 command. |
A refined temperature parser might look below, it should be able to parse the response of M105, M109, M190. See Marlin/Marlin_main.cpp for details. const parse = (line) => {
const payload = {};
let r = line.match(/^(?:ok)?\s*(?:(?:(T|B|T\d+):([0-9\.\-]+)\s+\/([0-9\.\-]+)(?:\s+\((?:[0-9\.\-]+)\))?)|(?:(@|B@|@\d+):([0-9\.\-]+))|(?:(W):(\?|[0-9]+)))/i);
if (!r) {
return null;
}
const re = /(?:(?:(T|B|T\d+):([0-9\.\-]+)\s+\/([0-9\.\-]+)(?:\s+\((?:[0-9\.\-]+)\))?)|(?:(@|B@|@\d+):([0-9\.\-]+))|(?:(W):(\?|[0-9]+)))/ig;
while((r = re.exec(line))) {
if (r[1]) { // T:293.0 /0.0
const key = r[1];
const current = Number(r[2]) || 0;
const target = Number(r[3]) || 0;
payload[key] = [current, target];
} else if (r[4]) { // @:0 or @B:0
const key = r[4];
const value = Number(r[5]) || 0;
payload[key] = value;
} else if (r[6]) { // W:? or W:9
const key = r[6];
const value = (r[7] === '?') ? r[7] : Number(r[7]);
payload[key] = value;
}
}
console.log(payload);
}; M105 parse('ok T:293.0 /0.0 B:25.9 /0.0 @:0 B@:0');
// { T: [ 293, 0 ], B: [ 25.9, 0 ], '@': 0, 'B@': 0 }
parse('ok T:293.0 /0.0 B:25.9 /0.0 T0:293.0 /0.0 T1:100.0 /0.0 @:0 B@:0 @0:0 @1:0');
// { T: [ 293, 0 ], B: [ 25.9, 0 ], T0: [ 293, 0 ], T1: [ 100, 0 ], '@': 0, 'B@': 0, '@0': 0, '@1': 0 }
parse('ok T:293.0 /0.0 (0.0) B:25.9 /0.0 T0:293.0 /0.0 (0.0) T1:100.0 /0.0 (0.0) @:0 B@:0 @0:0 @1:0');
// { T: [ 293, 0 ], B: [ 25.9, 0 ], T0: [ 293, 0 ], T1: [ 100, 0 ], '@': 0, 'B@': 0, '@0': 0, '@1': 0 }
parse('ok T:293.0 /0.0 (0.0) B:25.9 /0.0 T0:293.0 /0.0 (0.0) T1:100.0 /0.0 (0.0) @:0 B@:0 @0:0 @1:0 W:?');
// { T: [ 293, 0 ], B: [ 25.9, 0 ], T0: [ 293, 0 ], T1: [ 100, 0 ], '@': 0, 'B@': 0, '@0': 0, '@1': 0, W: '?' }
parse('ok T:293.0 /0.0 (0.0) B:25.9 /0.0 T0:293.0 /0.0 (0.0) T1:100.0 /0.0 (0.0) @:0 B@:0 @0:0 @1:0 W:0');
// { T: [ 293, 0 ], B: [ 25.9, 0 ], T0: [ 293, 0 ], T1: [ 100, 0 ], '@': 0, 'B@': 0, '@0': 0, '@1': 0, W: 0 } M109 / M190 parse(' T:293.0 /0.0 B:25.9 /0.0 @:0 B@:0');
// { T: [ 293, 0 ], B: [ 25.9, 0 ], '@': 0, 'B@': 0 }
parse(' T:293.0 /0.0 B:25.9 /0.0 T0:293.0 /0.0 T1:100.0 /0.0 @:0 B@:0 @0:0 @1:0');
// { T: [ 293, 0 ], B: [ 25.9, 0 ], T0: [ 293, 0 ], T1: [ 100, 0 ], '@': 0, 'B@': 0, '@0': 0, '@1': 0 }
parse(' T:293.0 /0.0 (0.0) B:25.9 /0.0 T0:293.0 /0.0 (0.0) T1:100.0 /0.0 (0.0) @:0 B@:0 @0:0 @1:0');
// { T: [ 293, 0 ], B: [ 25.9, 0 ], T0: [ 293, 0 ], T1: [ 100, 0 ], '@': 0, 'B@': 0, '@0': 0, '@1': 0 } |
I made it works with my master branch, you can see my commits at Source Code Controller State {
port: "/dev/tty.wchusbserialfa130",
baudrate: 115200,
sockets: [
"YF7zNKTPtZ_H7DEPAAAB"
],
ready: true,
controller: {
type: "Marlin",
settings: {
firmwareName: "Marlin 1.1.0",
protocolVersion: "1.0",
machineType: "3D",
extruderCount: 1,
uuid: "cede2a2f-41a2-4748-9b12-c55c62f367ff"
},
state: {
pos: {
x: "0.00",
y: "0.00",
z: "0.00",
e: "0.00"
},
modal: {
motion: "G0",
wcs: "G54",
plane: "G17",
units: "G21",
distance: "G90",
feedrate: "G94",
program: "M0",
spindle: "M5",
coolant: "M9"
},
ovF: 100,
ovS: 100,
heater: {
extruder: {
deg: "41.4",
degTarget: "40.0",
power: "2"
},
bed: {
deg: "25.2",
degTarget: "0.0",
power: "0"
},
wait: "0"
},
rapidFeedrate: 0,
feedrate: 0,
spindle: 0
}
},
feeder: {
hold: false,
holdReason: null,
queue: 0,
pending: false,
changed: false
},
sender: {
sp: 0,
hold: true,
holdReason: {
data: "M109"
},
name: "jsdc-snapmaker.nc",
context: {
xmin: 0,
xmax: 0,
ymin: 0,
ymax: 0,
zmin: 0,
zmax: 0,
posx: 0,
posy: 0,
posz: 0,
pose: 0,
modal: {
motion: "G0",
wcs: "G54",
plane: "G17",
units: "G21",
distance: "G90",
feedrate: "G94",
program: "M0",
spindle: "M5",
coolant: "M9"
}
},
size: 21284,
total: 927,
sent: 1,
received: 1,
startTime: 1510589200696,
finishTime: 0,
elapsedTime: 48293,
remainingTime: 44719318
},
workflow: {
state: "running"
}
} |
Still checking |
Hi, cheton, 我特别喜欢你加的新功能, 温度加热的提示框以及加热是那个闪烁得小图标很赞! 我把你代码拉下来来测试一下, 尝试发送3D 打印的GCode, 还是会有问题, GCode 发送会被截断 Background关于要不要做行校验的问题, 我和我们的固件工程师讨论交流之后得出了以下结论。 Requirement
Design
发出指令
总结
|
P.S. 最近要照顧家裡的兩個小孩,常常時間不太夠用,所以有時候會晚些才回覆 :P |
感謝你的幫忙,經過這幾天的修改後應該可以動了,目前是用你給的 G-code sample 做測試。 我簡要說明一下這邊的修改
|
感谢! 已参照你的更改重构了代码 其中我发现两个小问题
有遇到两个问题, 一直不知道怎么解决, 不知道你有没有遇到过
我觉得这两个问题可能有相关性。 猜测是不是因为后台还没有准备好, 前端就开始请求资源。 |
感謝你回報的兩個問題,剛剛已經一併修正了 cncjs/cncjs@653b418 黑屏問題我在 Electron 遇過不少次,但一直找不出真正的原因,不過根據你找出的連結看來,在 Node.js webpack-contrib/webpack-hot-middleware#210 (comment) |
Electron v1.8.1 (https://github.com/electron/electron/releases/tag/v1.8.1)
從 Electron 1.8.1 開始升級了 Node.js 版號到 8.2.1,可以安裝 Electron 1.8 跑看看 npm install --save-dev electron@1.8.2-beta.2 |
Just to mention that there is a bug in MarlinController.js. You can refer to the commit for the bug fix. |
Hi @whimsycwd
With the above code, the
moveOn()
function is called within the "others" event callback. The "others" event will be emitted if the message was not able to parse (see https://github.com/whimsycwd/snapjs/blob/master/src/app/controllers/Marlin/Marlin.js#L349-L351).May I know for what kinds of messages that need to handle in the "others" callback when running a G-code program? Thank you.
The text was updated successfully, but these errors were encountered: