I want to access the bed temperature of the 3D printer. I am able to get the temperatures using serial connection (Thanks to Demetris's help (Access Temperature sensor data of 3D printer via Serial connection)). The problem that I am facing now is that as soon as I give the command, I get the temperature values, however the print job stops. Is there a way around it? I want to get the temperature values as the print job goes on. TIA!
Opening a serial connection to your printer will usually reset the microcontroller, stopping the print.
The serial interface has a line known as request to send (RTS) that indicates to the microcontroller that the computer is ready to receive data. When the port is closed, this line is HIGH (indicating the computer is not ready), and when you open the serial connection the line goes LOW (indicating the computer is ready now) and the transition from HIGH to LOW triggers a reset.
There are a number of ways to prevent this:
In software: disable hang up on close (HUPCL). This prevents the RTS line from going HIGH after you close it, allowing it to be subsequently opened without causing a reset. However, this does not work for the first attempt (the first, initial connection still causes a reset). How this is configured depends on your software/driver set up, but it is widely supported.
In software: disable the RTS line from going LOW in the first place. I'm not sure if this is readily possible with common serial drivers.
In software: modify your workflow to always keep the connection open, preventing the associated reset from happening.
In hardware: your printer's board will have some circuitry on there that translates the RTS line transitioning from HIGH to LOW to trigger a reset, usually this is implemented in the form of a single capacitor between RTS and RST. RST is normally pulled high with a pull-up resistor (on the order of 10k or so), and when RTS transitions to low the capacitor briefly allows some current to flow, pulling RST low. One way to prevent this is to include a stronger pull-up resistor that overcomes the current drain associated with the RTS line going LOW. DisablingAutoResetOnSerialConnection suggests using a 330 Ohm resistor between VCC and GND.
In hardware: desolder the capacitor mentioned earlier.