Control & UCI Advanced: IN-HOUSE ONLY Training : Lighting Control Revisited
At 19:05, there is an error in the code left on Nate’s screen. Before opening the while loop, we need to attempt the ReadLine. If ReadLine is successful, we will get a string and enter the loop for parsing and additional attempts at ReadLines. If ReadLine is unsuccessful, we will get nil and never enter the loop. This approach will ensure that all complete responses are handled, while also ensuring that any partial responses are left in the buffer for processing in the next .Data event.
tempDATA_WE_TAKING = NATELIGHTS:ReadLine(TcpSocket.EOL.Custom, "\r") --Attempt to read a complete line
while tempDATA_WE_TAKING ~= nil do --while we are successful at reading lines
GETTHATNUMBEROUTTHATDATA(tempDATA_WE_TAKING) --parse line
tempDATA_WE_TAKING = NATELIGHTS:ReadLine(TcpSocket.EOL.Custom, "\r") --attempt to read next line
end