๋ฐฐ์ด์ ๋ฐ์ดํฐ๋ฅผ ์ถ๊ฐํ๊ฑฐ๋ ์ญ์ ํ๊ณ ์ถ์๋ ์ฌ์ฉํ๋ ํจ์์ด๋ค.
๋ฐฐ์ด์ด๋ฆ์ ์ง๊ธ UART ํ ์คํธํ๋๋๊ณ rx_buff๋ผ๊ณ ๋ง๋ค์๋ค. ์๋ฌด ์ด๋ฆ์ด๋ ์๊ด์๋ค.
์๋ sizeof ์๋ฆฌ๋ ๋ฌธ์์ด์ ๋ฐฐ์ด์ ์ถ๊ฐํ๊ณ ์ถ์๋๋ strlen์ ์ฌ์ฉํ๋ฉด ๋๋ค.
void insert(U08 index, U08 ch)
{
memmove(rx_buff + index + 1, rx_buff + index, sizeof(rx_buff) - index + 1);
rx_buff[index] = ch;
}
// ex : insert(1, 0xff);
void delete(U08 index)
{
memmove(rx_buff + index, rx_buff + index + 1, sizeof(rx_buff) - index);
}
// ex : delete(1);
void append(U08 ch)
{
insert(sizeof(rx_buff), ch);
}
// ex : append(0xff);
๋ฐ์ํ
'Programming Language' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ณธ๋ฌธ์์ ์ ๊ธฐ, ํผ์น๊ธฐ ๊ธฐ๋ฅ ์ถ๊ฐํ๊ธฐ (0) | 2023.03.09 |
---|---|
๋ฌธ์์ด ๋ณต์ฌ ํจ์์ธ strcpy (0) | 2023.03.07 |
VT100์ ์ด์ฉํ์ฌ ์ฝ์ ๋ง๋ค๊ธฐ (0) | 2022.09.07 |
C์ธ์ด, ๋ ํผ๋ฐ์ค(Reference) '&' ์ธ์ ์ฐ๋๊ฑฐ์ง? (0) | 2022.07.23 |
C์ธ์ด์์ ํฌ์ธํฐ๊ฐ ๊ทธ๋ฆฌ ์ค์ํ๊ฐ? ์ .. (0) | 2022.07.23 |
์ต๊ทผ๋๊ธ