Sending gcode string to 3D printer through a serial port

2.8k views Asked by At

I am trying to display a message on my FlashForge Creator Pro (dual) 3D printer by sending the Gcode to the printer through serial communication.

When I open the ReplicatorG software and place the string:

M70 P5; Hello World.

And click "Build" everything works fine and the machine shows the display as it should. However when I use it in my code (nodejs/node-serialport) it doesn't work:

require('serialport')

var sp = new SerialPort("/dev/tty.usbmodem1441", {
  baudrate: 56700,
  parser: serialport.parsers.readline("\n")
});

sp.on("open", function(){
  console.log('open');

  sp.on('data', function(data) {
    console.log('data received: ' + data);
  });

  sp.write("M70 P5; Hello World.", function(err, results) {
    console.log('err ' + err);
    console.log('results ' + results);
  });
});

The baud rate which it uses to connect to the printer has been taken from the ReplicatorG The Creator Dual driver which is also used when sent by ReplicatorG.

The console emits the "open" event without any errors.

I've tried to add the "%" character at the beginning and the end of the command and seperate the lines by adding '\n' but have yet to succeed. What am I doing wrong?

1

There are 1 answers

0
dennis On BEST ANSWER

I finally found a way to do it:

My flashforge is running sailfish 7.7 which doesn't recognize gcode commands. instead it requires a x3g file which is then written to the serialport.

I found a way of using GPX: https://github.com/whpthomas/GPX

which allows to me to input a gcode file and automaticly write it to the serial port.

I hope this helps someone else.