MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / RawMessage

Method RawMessage

src/Platform/Platform.cpp:2951–3040  ·  view source on GitHub ↗

Send the specified message to the specified destinations. The Error and Warning flags have already been handled.

Source from the content-addressed store, hash-verified

2949
2950// Send the specified message to the specified destinations. The Error and Warning flags have already been handled.
2951void Platform::RawMessage(const GCodeBuffer *_ecv_null gb, MessageType type, const char *_ecv_array message) noexcept
2952{
2953#if HAS_MASS_STORAGE
2954 // Deal with logging
2955 if (logger != nullptr)
2956 {
2957 logger->LogMessage(realTime, message, type);
2958 }
2959#endif
2960
2961 // Send the message to the destinations
2962 if ((type & ImmediateAuxMessage) != 0)
2963 {
2964 SendPanelDueMessage(1, message);
2965 }
2966 else if ((type & AuxMessage) != 0)
2967 {
2968 AppendAuxReply(0, gb, message, message[0] == '{' || (type & RawMessageFlag) != 0);
2969 }
2970
2971 if ((type & HttpMessage) != 0)
2972 {
2973 reprap.GetNetwork().HandleHttpGCodeReply(message);
2974 }
2975
2976 if ((type & TelnetMessage) != 0)
2977 {
2978 reprap.GetNetwork().HandleTelnetGCodeReply(message);
2979 }
2980
2981 if ((type & Aux2Message) != 0)
2982 {
2983 AppendAuxReply(1, gb, message, message[0] == '{' || (type & RawMessageFlag) != 0);
2984 }
2985
2986 if ((type & BlockingUsbMessage) != 0)
2987 {
2988 // Debug output sends messages in blocking mode. We now give up sending if we are close to software watchdog timeout.
2989 MutexLocker lock(usbMutex);
2990 const char *_ecv_array p = message;
2991 size_t len = strlen(p);
2992 while (SERIAL_MAIN_DEVICE.IsConnected() && len != 0 && !reprap.SpinTimeoutImminent())
2993 {
2994 const size_t written = SERIAL_MAIN_DEVICE.print(p, len);
2995 len -= written;
2996 p += written;
2997 }
2998 // We no longer flush afterwards
2999 }
3000 else if ((type & UsbMessage) != 0)
3001 {
3002 // Message that is to be sent via the USB line (non-blocking)
3003 MutexLocker lock(usbMutex);
3004
3005 if (GetChannelMode(0) == AuxMode::raw || message[0] == '{' || (type & RawMessageFlag) != 0)
3006 {
3007 // Ensure we have a valid buffer to write to that isn't referenced for other destinations
3008 OutputBuffer *_ecv_null usbOutputBuffer = usbOutput.GetLastItem();

Callers

nothing calls this directly

Calls 6

LogMessageMethod · 0.80
SpinTimeoutImminentMethod · 0.80
IsReferencedMethod · 0.80
PushMethod · 0.80
catMethod · 0.80
catfMethod · 0.80

Tested by

no test coverage detected