我有一些很難理解Bitwise-And
和Unary Complement
時,無論是在此代碼段理解「按位與(&)」和「一元補碼(〜)」在C++中
if((oldByte==m_DLE) & (newByte==m_STX)) {
int data_index=0;
//This below line --- does it returns true if both the oldByte and newByte are not true
//and within timeout
while((timeout.read_s()<m_timeout) & ~((oldByte==m_DLE) & (newByte==m_ETX))) {
if(Serial.available()>0) {
oldByte=newByte;
newByte=Serial.read();
if(newByte==m_DLE) {
.
.
.
使用是兩個運營商& ~
像被檢查執行邏輯不操作,直到如果兩個oldByte
和newByte
是假
上面的代碼是從link - 的代碼>線227
我試圖使用C,但沒有定時功能
if((oldByte==DLE) && (newByte== STX)) {
data_index = 0;
// is this the correct implematation for above C++ code to C
while(! ((oldByte== DLE) && (newByte== ETX))){
oldByte = newByte;
的實現我的應用程序的代碼是這種方法正確實現用C
請求程序員對代碼進行模糊處理。 (幾個&看起來像一個邏輯&&) –
@DieterLücking - 我試過了,但沒有迴應..有點舊的帖子在GitHub – user2345
C&C++不是同一種語言。標籤(正確設置時)旨在節省時間。 –