Git Product home page Git Product logo

nilrtos-arduino's People

Contributors

codingforfun avatar greiman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nilrtos-arduino's Issues

nilSemWaitTimeout() returning NIL_MSG_OK on timeout condition

On 1.8.0 IDE on UNO:

On this fragment:

SEMAPHORE_DECL(semRGB, 0);
...
NIL_THREAD(ThreadRGB, arg) {
while (true) {
static systime_t WaitMillis = 10;
msg_t semmsg = nilSemWaitTimeout(&semRGB, WaitMillis);
if (semmsg == NIL_MSG_TMO) {
...
} else { // got signaled
...
}
}
... on timeout conditions never enters the if true block. semmsg prints out as 0, which I take is NIL_MSG_OK. The elapsed time of the requested timeout is correct.
As such one cannot distinguish between a timeout and receiving a message as per the documentation:

/**

  • @brief Performs a wait operation on a semaphore with timeout specification.
  • @param[in] sp pointer to a @p semaphore_t structure
  • @param[in] timeout the number of ticks before the operation timeouts,
  •                  the following special values are allowed:
    
  •                  - @a TIME_IMMEDIATE immediate timeout.
    
  •                  - @a TIME_INFINITE no timeout.
    
  •                  .
    
  • @return A message specifying how the invoking thread has been
  •                  released from the semaphore.
    
  • @RetVal NIL_MSG_OK if the thread has not stopped on the semaphore or the
  •                  semaphore has been signaled.
    
  • @RetVal NIL_MSG_RST if the semaphore has been reset using @p nilSemReset().
  • @RetVal NIL_MSG_TMO if the semaphore has not been signaled or reset within
  •                  the specified timeout.
    
  • @api
    */
    msg_t nilSemWaitTimeout(semaphore_t *sp, systime_t timeout) {
    msg_t msg;

nilSysLock();
msg = nilSemWaitTimeoutS(sp, timeout);
nilSysUnlock();
return msg;
}

There is evidence that the semiphore/task system is set up properly as
nilSemWait() properly fires when signaled.

Is there a reference manual that is generated by these headers?
I find the online reference here: http://chibios.sourceforge.net/docs3/nil/structnil__semaphore.html
confusing because it reads like a mashup of Chibi and NIL, with many references to ch
prefixed items.

Problem with NilSerial

Hi,

I hope you can help. I have a thread that monitors incoming serial communications but it only reads 3 characters - the first 2 and the last one.

For instance, if I enter 123456 and press send in the arduino serial monitor, I get this:

----------------------SerialIn = 126

The arduino library code in Hardware.h/.cpp *works( as expected.

I have looked at the code for Serial.read. It seems pretty straightforward and just gets a character from the USB data register.

/**
 *  Unbuffered read
 *  @return -1 if no character is available or an available character.
 */
int NilSerialClass::read() {
  if (UCSR0A & (1 << RXC0)) return UDR0;
  return -1;
}

I have tried with different baud rates (down to 2400) with no change in behaviour.

Here is the code: (comment out the #define in line 2 to use default, working Serial implementation)

#include <NilSerial.h>
#define Serial NilSerial

char buffer[11];
int offset;

void setup()
{
  Serial.begin(115200);
  offset = 0;
  memset(buffer, 0, sizeof(buffer));
}

void loop()
{
  int value = Serial.read();
  if (value == -1)
  {
    if (offset)
    {
      Serial.print("SerialIn");
      Serial.println(buffer);
      offset = 0;
      memset(buffer, 0, sizeof(buffer));
    }    
//    nilThdSleep(1);     
  }
  else
  {
    //psPrintf(Serial, "X");       
    buffer[offset++] = value; 
  }

}

I'm now stuck. Any help would be appreciated.

Regards,
Mark

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.