Pages: 1 ... 27 28 [29]   Go Down
Author Topic: Cosa: An Object-Oriented Platform for Arduino programming  (Read 75543 times)
0 Members and 4 Guests are viewing this topic.
Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 438
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I can see new shell function "execute_P", I believe it is taking the input from the prog mem instead of the buffer? I didn't find it in the online documentation.
@g_ad

That one is easy; my dropbox has not yet synced the latest update. But it should be ready now.

Could you please tell me one more small thing that I didn't find the answer for yet - how to understand the uart blocking and non blocking "uart.set_blocking(SLEEP_MODE_IDLE)" what does it actually do?
The issue is what should uart.gets() do when there is no more characters in the input buffer. The non-blocking behavior is to return directly with what was available. That would require building up the command line until the new-line character is seen.

The set_blocking() tells the device to wait for more characters and return when it receives the new-line. The function gets() will call yield() while waiting for more character. And the actual sleep mode is defined by the implementation of yield(). There are two major implementations of yield(). One that uses power down and the second that does context switches.

Links down the rabbit hole.
https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/IOStream.cpp#L355
https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/main.cpp#L118
https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Nucleo/Thread.cpp#L31

Cheers!
« Last Edit: July 24, 2014, 03:26:30 pm by kowalski » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@kowalski
The issue is what should uart.gets() do when there is no more characters in the input buffer. The non-blocking behavior is to return directly with what was available. That would require building up the command line until the new-line character is seen.

The set_blocking() tells the device to wait for more characters and return when it receives the new-line. The function gets() will call yield() while waiting for more character. And the actual sleep mode is defined by the implementation of yield(). There are two major implementations of yield(). One that uses power down and the second that does context switches.

Links down the rabbit hole.
https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/IOStream.cpp#L355
https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/main.cpp#L118
https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Nucleo/Thread.cpp#L31

Thank you, I was already exploring some  parts of the rabbit hole smiley but there is plenty of interesting stuff for many different adventures smiley-wink.

Thanks to your answer I actually spotted something that I've ignored before - the shell handling actually blocks the main loop waiting for the command line and it might interfere if there is some sort of "multitasking" ...
First I'm going to get familiar with the library and next I will mess a bit to capture the string incoming from uart and pass it to the shell when ready so it will not block the main loop smiley.

Appreciate your help as always,
Kind regards,
Adam
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@kowalski

I think I've found some weakens in CosaShell - if you provide too long string of arguments it doesn't return some sort of error -illegal argument but processes part of the arguments and continues with the rest of the string after, please see :

entered from terminal:
Code:
args 1111111111 2222222222 3333333333 4444444444 5555555555 6666666666

system response:
Code:
arduino:$ args 1111111111 2222222222 3333333333 4444444444 5555555555 666
argument: 1111111111
argument: 2222222222
argument: 3333333333
argument: 4444444444
argument: 5555555555
argument: 666
arduino:$ 6666666
illegal command
arduino:$

Kind regards,
Adam
Logged

Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 438
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@g_ad

That is actually exactly the behavior it "should" have right now when the line is too long. The input buffer is limited to 64 characters (in the current version). It is a configuration variable. The error handling could be improved. Please see the configuration constants: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Shell.hh#L117

I will see what I can do about that in Shell::run() as the too long command lines will result in multiple gets() calls. These will have to be ignored and reported as an error.

Latest update; The script handling will allow parameter binding (standard shell script syntax, $1 for parameter/option one, etc). Please see the updated CosaShell.ino/Commands.cpp. The script blink will require a delay time parameter (in ms).

Cheers!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@kowalski
That is actually exactly the behavior it "should" have right now when the line is too long. The input buffer is limited to 64 characters (in the current version). It is a configuration variable. The error handling could be improved. Please see the configuration constants: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Shell.hh#L117

I will see what I can do about that in Shell::run() as the too long command lines will result in multiple gets() calls. These will have to be ignored and reported as an error.

Thank you Mikael, please treat my posts informational, by any mean not as a change request, I only shared it as result of the crash testing smiley-wink and if it can help you with the development that's good, otherwise just ignore it smiley. I'm happy to do some beta/stress testing smiley-wink

I think I'm going to capture the uart in the main loop and pass the string to shell when the command line is ready to be processed so I will not block the main loop while waiting for the command line, this way I can quite easily test the string before passing it to shell to avoid multiple gets() calls smiley.

Kind regards,
Adam
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@kowalski

After the latest update the CosaShell example doesn't compile:
Code:
In file included from /Commands.h:27,
                 from Commands.cpp:21:
... \arduino-1.0.5-r2\hardware\Cosa\cores\cosa/Cosa/Shell.hh:121: error: ISO C++ forbids initialization of member 'ARGV_MAX'
... \arduino-1.0.5-r2\hardware\Cosa\cores\cosa/Cosa/Shell.hh:121: error: making 'ARGV_MAX' static

Kind regards,
Adam
Logged

Sweden
Offline Offline
Sr. Member
****
Karma: 11
Posts: 438
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@g_ad

Update available that fixes that for Arduino 1.0.X.

BW: It is better to use the github issues list for this type of problems.

Cheers!
« Last Edit: Today at 06:11:35 pm by kowalski » Logged

Pages: 1 ... 27 28 [29]   Go Up
Jump to: