Skip to content

Commit

Permalink
gibberich removed once and for all by discarding first non blocking r…
Browse files Browse the repository at this point in the history
…ead issue #2 solved
  • Loading branch information
wassfila committed Oct 6, 2016
1 parent 0bdf90d commit d794955
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ws05_IoT_Mobile_Node/spr01_UART_Server/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Parameters:
Optionnal
e.g 'logfile=logfile.txt'

- logcmd: e.g 'logcmd=1'
- logout: e.g 'logcmd=1'
Optional

- configfile:
Expand Down
13 changes: 11 additions & 2 deletions ws05_IoT_Mobile_Node/spr01_UART_Server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ int main( int argc, char** argv )
std::cout << "logfile = " << conf["logfile"] << std::endl;
ser.start_logfile(conf["logfile"]);
}
if(utl::exists(conf,"logout"))
{
std::cout << "logout = " << conf["logout"] << std::endl;
ser.isLogOut = true;//by default
if(conf["logout"] == "0")
{
ser.isLogOut = false;
}
}
if(utl::exists(conf,"port"))
{
std::cout << "port = " << conf["port"] << std::endl;
Expand All @@ -63,11 +72,11 @@ int main( int argc, char** argv )



//std::cout << MAGENTA << "Colored " << CYAN << "Text" << RESET << std::endl;
//discard first trash buffer if available right after opening the port
ser.update();

while (1)
{
//display Received log
if(ser.update())
{
ser.logBuffer();
Expand Down
4 changes: 4 additions & 0 deletions ws05_IoT_Mobile_Node/spr01_UART_Server/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ void Serial::start_logfile(std::string fileName)
void Serial::start(std::string port_name,bool s_500)
{
std::string strlog;

isLogFile = true;
isLogOut = true;

fd = open (port_name.c_str(), O_RDWR | O_NOCTTY | O_SYNC);
if (fd >= 0)
{
Expand Down
2 changes: 2 additions & 0 deletions ws05_IoT_Mobile_Node/spr01_UART_Server/serial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Serial
public:
std::string Name;
std::ofstream logfile;
bool isLogFile;
bool isLogOut;
public:
void start(std::string port_name,bool s_500 = false);
void start_logfile(std::string fileName);
Expand Down

0 comments on commit d794955

Please sign in to comment.