Go to the source code of this file.
Data Structures | |
union | serial_linestate_t |
union | io_stream_flags_t |
union | io_stream_state_t |
struct | io_stream_t |
Properties and handlers for stream I/O. More... | |
struct | io_stream_properties_t |
struct | io_stream_details |
struct | stream_rx_buffer_t |
struct | stream_tx_buffer_t |
struct | stream_block_tx_buffer_t |
struct | stream_block_tx_buffer2_t |
Macros | |
#define | ASCII_SOH 0x01 |
#define | ASCII_STX 0x02 |
#define | ASCII_ETX 0x03 |
#define | ASCII_EOT 0x04 |
#define | ASCII_ENQ 0x05 |
#define | ASCII_ACK 0x06 |
#define | ASCII_BS 0x08 |
#define | ASCII_TAB 0x09 |
#define | ASCII_LF 0x0A |
#define | ASCII_CR 0x0D |
#define | ASCII_XON 0x11 |
#define | ASCII_XOFF 0x13 |
#define | ASCII_NAK 0x15 |
#define | ASCII_EOF 0x1A |
#define | ASCII_CAN 0x18 |
#define | ASCII_EM 0x19 |
#define | ASCII_ESC 0x1B |
#define | ASCII_DEL 0x7F |
#define | ASCII_EOL "\r\n" |
#define | RX_BUFFER_SIZE 1024 |
#define | TX_BUFFER_SIZE 512 |
#define | BLOCK_TX_BUFFER_SIZE 256 |
#define | BAUD_RATE 115200 |
#define | SERIAL_NO_DATA -1 |
#define | BUFNEXT(ptr, buffer) ((ptr + 1) & (sizeof(buffer.data) - 1)) |
#define | BUFCOUNT(head, tail, size) ((head >= tail) ? (head - tail) : (size - tail + head)) |
#define | DEBUG_PRINT 0 |
#define | debug_print(fmt, ...) do { if(DEBUG_PRINT) debug_printf(fmt, __VA_ARGS__); } while(0) |
Typedefs | |
typedef bool(* | stream_is_connected_ptr) (void) |
Pointer to function for getting stream connected status. More... | |
typedef uint16_t(* | get_stream_buffer_count_ptr) (void) |
Pointer to function for getting number of characters available or free in a stream buffer. More... | |
typedef int16_t(* | stream_read_ptr) (void) |
Pointer to function for reading a single character from a input stream. More... | |
typedef void(* | stream_write_ptr) (const char *s) |
Pointer to function for writing a null terminated string to the output stream. More... | |
typedef void(* | stream_write_n_ptr) (const char *s, uint16_t len) |
Pointer to function for writing a n character long string to the output stream. More... | |
typedef bool(* | stream_write_char_ptr) (const char c) |
Pointer to function for writing a single character to the output stream. More... | |
typedef bool(* | enqueue_realtime_command_ptr) (char c) |
Pointer to function for extracting real-time commands from the input stream and enqueue them for processing. This should be called by driver code prior to inserting a character into the input buffer. More... | |
typedef bool(* | enqueue_realtime_command2_ptr) (char c) |
Optional, but recommended, pointer to function for enqueueing realtime command characters. More... | |
typedef enqueue_realtime_command_ptr(* | set_enqueue_rt_handler_ptr) (enqueue_realtime_command_ptr handler) |
Pointer to function for setting the enqueue realtime commands handler. More... | |
typedef bool(* | set_baud_rate_ptr) (uint32_t baud_rate) |
Pointer to function for setting the stream baud rate. More... | |
typedef void(* | flush_stream_buffer_ptr) (void) |
Pointer to function for flushing a stream buffer. More... | |
typedef void(* | cancel_read_buffer_ptr) (void) |
Pointer to function for flushing the input buffer and inserting an ASCII_CAN character. More... | |
typedef bool(* | suspend_read_ptr) (bool await) |
Pointer to function for blocking reads from and restoring a input buffer. More... | |
typedef bool(* | disable_rx_stream_ptr) (bool disable) |
Pointer to function for disabling/enabling stream input. More... | |
typedef void(* | on_linestate_changed_ptr) (serial_linestate_t state) |
Pointer to function for handling line state changed events. More... | |
typedef const io_stream_t *(* | stream_claim_ptr) (uint32_t baud_rate) |
typedef bool(* | stream_enumerate_callback_ptr) (io_stream_properties_t const *properties) |
typedef struct io_stream_details | io_stream_details_t |
Enumerations | |
enum | stream_type_t { StreamType_Serial = 0 , StreamType_MPG , StreamType_Bluetooth , StreamType_Telnet , StreamType_WebSocket , StreamType_SDCard , StreamType_File = StreamType_SDCard , StreamType_Redirected , StreamType_Null } |
Functions | |
int16_t | stream_get_null (void) |
Dummy function for reading data from a virtual empty input buffer. More... | |
bool | stream_rx_suspend (stream_rx_buffer_t *rxbuffer, bool suspend) |
Function for blocking reads from or restoring an input buffer. More... | |
bool | stream_mpg_register (const io_stream_t *stream, bool rx_only, stream_write_char_ptr write_char) |
bool | stream_mpg_enable (bool on) |
Function for enabling/disabling input from a secondary input stream. More... | |
void | stream_mpg_set_mode (void *data) |
bool | stream_mpg_check_enable (char c) |
bool | stream_buffer_all (char c) |
bool | stream_tx_blocking (void) |
bool | stream_enqueue_realtime_command (char c) |
void | stream_register_streams (io_stream_details_t *details) |
bool | stream_enumerate_streams (stream_enumerate_callback_ptr callback) |
bool | stream_connect (const io_stream_t *stream) |
bool | stream_connect_instance (uint8_t instance, uint32_t baud_rate) |
void | stream_disconnect (const io_stream_t *stream) |
bool | stream_connected (void) |
const io_stream_t * | stream_get_base (void) |
io_stream_flags_t | stream_get_flags (io_stream_t stream) |
const io_stream_t * | stream_null_init (uint32_t baud_rate) |
io_stream_t const * | stream_open_instance (uint8_t instance, uint32_t baud_rate, stream_write_char_ptr rx_handler, const char *description) |
bool | stream_set_description (const io_stream_t *stream, const char *description) |
void | debug_printf (const char *fmt,...) |
Stream I/O functions structure for the HAL.
Helper functions for saving away and restoring a stream input buffer. Not referenced by the core.
#define ASCII_ACK 0x06 |
#define ASCII_BS 0x08 |
#define ASCII_CAN 0x18 |
#define ASCII_CR 0x0D |
#define ASCII_DEL 0x7F |
#define ASCII_EM 0x19 |
#define ASCII_ENQ 0x05 |
#define ASCII_EOF 0x1A |
#define ASCII_EOL "\r\n" |
#define ASCII_EOT 0x04 |
#define ASCII_ESC 0x1B |
#define ASCII_ETX 0x03 |
#define ASCII_LF 0x0A |
#define ASCII_NAK 0x15 |
#define ASCII_SOH 0x01 |
#define ASCII_STX 0x02 |
#define ASCII_TAB 0x09 |
#define ASCII_XOFF 0x13 |
#define ASCII_XON 0x11 |
#define BAUD_RATE 115200 |
#define BLOCK_TX_BUFFER_SIZE 256 |
#define BUFCOUNT | ( | head, | |
tail, | |||
size | |||
) | ((head >= tail) ? (head - tail) : (size - tail + head)) |
#define BUFNEXT | ( | ptr, | |
buffer | |||
) | ((ptr + 1) & (sizeof(buffer.data) - 1)) |
#define DEBUG_PRINT 0 |
#define debug_print | ( | fmt, | |
... | |||
) | do { if(DEBUG_PRINT) debug_printf(fmt, __VA_ARGS__); } while(0) |
#define RX_BUFFER_SIZE 1024 |
#define SERIAL_NO_DATA -1 |
#define TX_BUFFER_SIZE 512 |
typedef void(* cancel_read_buffer_ptr) (void) |
Pointer to function for flushing the input buffer and inserting an ASCII_CAN character.
This function is typically called by the enqueue_realtime_command handler when CMD_STOP or CMD_JOG_CANCEL character is processed. The ASCII_CAN character might be checked for and used by upstream code to flush any buffers it may have.
typedef bool(* disable_rx_stream_ptr) (bool disable) |
Pointer to function for disabling/enabling stream input.
Typically used to disable receive interrupts so that real-time command processing for the stream is blocked. Usually it is desirable to block processing when another stream provides the input, but sometimes not. E.g. when input is from a SD card real-time commands from the stream that initiated SD card streaming is needed for handing feed-holds, overrides, soft resets etc.
disable | true to disable stream, false to enable, |
typedef bool(* enqueue_realtime_command2_ptr) (char c) |
Optional, but recommended, pointer to function for enqueueing realtime command characters.
c | character to enqueue. |
NOTE: Stream implementations should pass the character over the current handler registered by the set_enqueue_rt_handler().
User or plugin code should not enqueue realtime command characters via this handler, it should call grbl.enqueue_realtime_command() instead.
typedef bool(* enqueue_realtime_command_ptr) (char c) |
Pointer to function for extracting real-time commands from the input stream and enqueue them for processing. This should be called by driver code prior to inserting a character into the input buffer.
c | character to check. |
typedef void(* flush_stream_buffer_ptr) (void) |
Pointer to function for flushing a stream buffer.
typedef uint16_t(* get_stream_buffer_count_ptr) (void) |
Pointer to function for getting number of characters available or free in a stream buffer.
typedef struct io_stream_details io_stream_details_t |
typedef void(* on_linestate_changed_ptr) (serial_linestate_t state) |
Pointer to function for handling line state changed events.
typedef bool(* set_baud_rate_ptr) (uint32_t baud_rate) |
Pointer to function for setting the stream baud rate.
baud_rate |
typedef enqueue_realtime_command_ptr(* set_enqueue_rt_handler_ptr) (enqueue_realtime_command_ptr handler) |
Pointer to function for setting the enqueue realtime commands handler.
handler | a enqueue_realtime_command_ptr pointer to the new handler function. |
NOTE: Stream implementations should hold a pointer to the handler in a local variable and typically set it to protocol_enqueue_realtime_command() on initialization.
typedef const io_stream_t*(* stream_claim_ptr) (uint32_t baud_rate) |
typedef bool(* stream_enumerate_callback_ptr) (io_stream_properties_t const *properties) |
typedef bool(* stream_is_connected_ptr) (void) |
Pointer to function for getting stream connected status.
typedef int16_t(* stream_read_ptr) (void) |
Pointer to function for reading a single character from a input stream.
typedef bool(* stream_write_char_ptr) (const char c) |
Pointer to function for writing a single character to the output stream.
c | the character to write. |
typedef void(* stream_write_n_ptr) (const char *s, uint16_t len) |
Pointer to function for writing a n character long string to the output stream.
s | pointer to string. |
len | number of characters to write. |
typedef void(* stream_write_ptr) (const char *s) |
Pointer to function for writing a null terminated string to the output stream.
s | pointer to null terminated string. |
NOTE: output might be buffered until an ASCII_LF is output, this is usually done by USB or network driver code to improve throughput.
typedef bool(* suspend_read_ptr) (bool await) |
Pointer to function for blocking reads from and restoring a input buffer.
This function is called with the await parameter true on executing a tool change command (M6), this shall block further reading from the input buffer. The core function stream_rx_suspend() can be called with the await parameter to do this, it will replace the hal.stream.read handler with a pointer to the dummy function stream_get_null().
Reading from the input is blocked until a tool change acknowledge character CMD_TOOL_ACK is received, when the driver receives this the input buffer is to be saved away and reading from the input resumed by restoring the hal.stream.read handler with its own read character function. Driver code can do this by calling the core function stream_rx_backup().
When the tool change is complete or a soft reset is executed the core will call this function with the await parameter false, if the driver code called stream_rx_suspend() to block input it shall then call it again with the await parameter as input to restore it.
await | bool |
enum stream_type_t |
void debug_printf | ( | const char * | fmt, |
... | |||
) |
bool stream_buffer_all | ( | char | c | ) |
bool stream_connect | ( | const io_stream_t * | stream | ) |
bool stream_connect_instance | ( | uint8_t | instance, |
uint32_t | baud_rate | ||
) |
bool stream_connected | ( | void | ) |
void stream_disconnect | ( | const io_stream_t * | stream | ) |
bool stream_enqueue_realtime_command | ( | char | c | ) |
bool stream_enumerate_streams | ( | stream_enumerate_callback_ptr | callback | ) |
const io_stream_t* stream_get_base | ( | void | ) |
io_stream_flags_t stream_get_flags | ( | io_stream_t | stream | ) |
int16_t stream_get_null | ( | void | ) |
Dummy function for reading data from a virtual empty input buffer.
bool stream_mpg_check_enable | ( | char | c | ) |
bool stream_mpg_enable | ( | bool | on | ) |
Function for enabling/disabling input from a secondary input stream.
on | true if switching input to mpg stream, false when restoring original input. |
bool stream_mpg_register | ( | const io_stream_t * | stream, |
bool | rx_only, | ||
stream_write_char_ptr | write_char | ||
) |
void stream_mpg_set_mode | ( | void * | data | ) |
const io_stream_t* stream_null_init | ( | uint32_t | baud_rate | ) |
io_stream_t const* stream_open_instance | ( | uint8_t | instance, |
uint32_t | baud_rate, | ||
stream_write_char_ptr | rx_handler, | ||
const char * | description | ||
) |
void stream_register_streams | ( | io_stream_details_t * | details | ) |
bool stream_rx_suspend | ( | stream_rx_buffer_t * | rxbuffer, |
bool | suspend | ||
) |
Function for blocking reads from or restoring an input buffer.
rxbuffer | pointer to a stream_rx_buffer_t. |
suspend | when true hal.stream.read is changed to stream_get_null(), if false it is restored if already saved. |
bool stream_set_description | ( | const io_stream_t * | stream, |
const char * | description | ||
) |
bool stream_tx_blocking | ( | void | ) |