Welcome! Log In Create A New Profile

Advanced

Cannot receive data from 3d printer but sending it successfully

Posted by mile 
Cannot receive data from 3d printer but sending it successfully
September 05, 2023 08:25AM
Hello, im trying to build a simple app as a learning project but im running some issues. So im successfully connecting through serial port and sending data to my printer (tried to send G28 and it homes) but when i try to read data for example i sent M503 i receive nothing. So my question is could it be that i need to set Databits, StopBit , Parity etc , if so where can i find them in my firmware. Im using Marlin 2.1.2 and Bigtreetech SKR 1.3. Thank you

Edited 1 time(s). Last edit at 09/05/2023 09:04AM by mile.
Attachments:
open | download - SerialConnection.cs (4.5 KB)
open | download - Untitled.png (25.6 KB)
Re: Cannot receive data from 3d printer but sending it successfully
September 05, 2023 09:18AM
I don't see an event handler to receive data

take a look at this
[www.c-sharpcorner.com]
Re: Cannot receive data from 3d printer but sending it successfully
September 06, 2023 05:11PM
public string Read()
{
Thread.Sleep(1000);
serialPort.ReadTimeout = 5000;
try
{
if (serialPort.IsOpen)
{
string data = serialPort.ReadLine();
DataRead?.Invoke(this, data);
return data;
}
return null;
}
catch (TimeoutException)
{
Console.WriteLine("Timeout: No data received within the specified time.");
return null;
}
catch (Exception ex)
{
// Handle the exception (e.g., log or display an error message)
Console.WriteLine($"Error reading from serial port: {ex.Message}");
ErrorOccurred?.Invoke(this, ex.Message);
return null;
}
}

I can't receive it just with this method ?
Sorry, only registered users may post in this forum.

Click here to login