Program C Ansi Programming Embedded Systems in C and C++ phần 8

Tham khảo tài liệu 'program c ansi programming embedded systems in c and c++ phần 8', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Method puts Description Copies the null-terminated string s to the serial port and appends a newline character. Notes In rare cases this function may return success though the newline was not actually sent. Returns The number of characters transmitted successfully. Otherwise -1 is returned to indicate error. int SerialPort puts const char s const char p Send each character of the string. for p s p 0 p if putchar p 0 break Add a newline character. putchar n return p - s 1 puts The receive method getchar is similar toputchar. It starts by checking if the receive buffer is empty. If so an error code is returned. Otherwise one byte of data is removed from the receive buffer and returned to the caller. The gets method calls getchar repeatedly until either a newline character is found or there is no more data available at the serial port. It then returns whatever string was found up to that point. The code for both of these methods follows Method getchar Description Read one character from the serial port. Notes Returns The next character found on this input stream. -1 is returned in the case of an error. int SerialPort getchar void int c if pRxQueue- isEmpty return -1 There is no input data available. int rxStalled pRxQueue- isFull Read the next byte out of the receive FIFO. c pRxQueue- remove If the receive engine is stalled restart it. if rxStalled channel return c getchar Method gets Description Collects a string of characters terminated by a newline character from the serial port and places it in s. The newline character is replaced by a null character. Notes The caller is responsible for allocating adequate space for the string. Warnings This function does not block waiting for a newline. If a complete string is not found it will return whatever is available in the receive queue. Returns A pointer to the string. Otherwise NULL is returned to indicate an error. char SerialPort gets char s char p int c Read characters until a newline is found or no more

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
14    100    4    29-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.