Pages: 1 ... 28 29 [30]   Go Down
Author Topic: Cosa: An Object-Oriented Platform for Arduino programming  (Read 83743 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 2
Posts: 59
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The news on the latest updates in Cosa.

1. IOStream
The IOStream class has a new member function to allow simple command line reading; IOStream::readline(buf, size). It will read available characters and append to the given string and return the buffer pointer when the line has been completed. The function will handle backspace, carriage-return and line-feed.

Does this mean that I can use the RFM69/nRF24 also to handle 'shell' commands? In other words I can easily create a serial to LAN/WiFi/Radio translator/gateway??

BTW: You seem to be working om my secret COSA wish list I have while developing prototype hardware. It's magic  smiley-twist
Logged

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

Does this mean that I can use the RFM69/nRF24 also to handle 'shell' commands? In other words I can easily create a serial to LAN/WiFi/Radio translator/gateway??
Not really there yet. You need an IOStream::Driver that will use a Wireless Driver for transportation. There is a mockup https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/IOStream/Driver/WIO.hh that does output only. See the example sketch https://github.com/mikaelpatel/Cosa/blob/master/examples/Wireless/CosaWirelessIOStream/CosaWirelessIOStream.ino. With input handling (i.e. recv) and buffering in the Shell you have all the necessary components for remote commands (at least on the NRF24L01P which has built-in acknowledgement and retransmission).

I am actually working on a telnet and http service that uses the shell. Seems like an interesting challenge. See how much of that ends up in the Cosa source.

BTW: You seem to be working om my secret COSA wish list I have while developing prototype hardware. It's magic  smiley-twist
I have suspected that we have somewhat the same agenda smiley

Cheers!
Logged

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

Some news on the latest updates in the Cosa project:

1. New pin index to Cosa pin symbol mapping.
In many example sketches there has been a need to map between a pin index to the program level pin symbol. There are two mapping tables available. See https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Board.hh#L100

2. More accurate delay when using the RTC class (timer that implement micros() and millis()).
The Cosa global delay() function is a function pointer and can be redefined. The default implementation uses busy-spin. When the Watchdog is used the Watchdog::delay() is installed instead. This gives low power mode during the delay. The Watchdog accuracy is at most 16 ms tick. When the RTC is used it will install the RTC::delay() function which also gives low power mode but also better accuracy (1 ms). The order of calling Watchdog and RTC begin() defines which version is used.

3. Telnet Shell example sketch.
The CosaShell example sketch has been integrated with the Telnet Server sketch to show how to communicate with the shell over Ethernet. Below is a screenshot with left) build, upload and serial monitoring, and right) telnet connection and commands to the shell.

For more details see https://github.com/mikaelpatel/Cosa/blob/master/examples/Ethernet/CosaTelnetShell/CosaTelnetShell.ino#L108

Cheers!
« Last Edit: August 01, 2014, 06:03:17 pm by kowalski » Logged

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

Some performance measurements on the Cosa Telnet Shell and a short update:

1. CosaTelnetShell performance
The test bench is an Arduino Mega 2560, Ethernet Shield and a D-Link DWL-810+ Ethernet Wifi Bridge. Connecting through a Wifi Router and back to a laptop (HP Probook 4540s with Ubuntu 12.04 LTS).

a. Max burst string output
To measure the performance of pure text output from the sketch the command "help" can be used. It will print the command help text. Using the command "repeat 1000 help" will generate a longer period to measure. The measured throughput on the laptop is 60-64 K received bytes per second for this test case (using GNOME Terminal/telnet and PuTTY).

The max performance when filling buffers on the W5100 is 250 KBps (8 MHz SPI, 4 byte command to transfer 1 byte data, 1/4 MBps). This is excluding chip select and all the commands necessary to initiate and check status for the W5100 SEND command.

b. Max analog sample rate
The command "analogread a4" will sample the analog pin a4 and print the value to the io-stream (socket). Again the repeat command can be used to find the upper limit of sampling, converting and sending per second; "repeat -t 2500 analogread a4" will measure the time to execute 2500 analogread. The max rate is between 2000-3000 samples per second (sample values are converted to text, printed to the iostream/socket and sent over Ethernet/Wifi).

The variation is due to other traffic and drops on Wifi but also the sample value as the text conversion time depends on the value. Please note that the max sample rate at 112 us per sample is 8900 samples per seconds. And that the above results is for a pure sequential implementation without interleaving. It is possible to, for instance, run number conversion to text in parallel with the sampling (ADC). This could give as much as 4000-5000 samples (in textual format) per second over Ethernet/Wifi from the Arduino board.

c. New example shell commands
i. Command "pinmode" to get or set the pin mode; input, output and pullup. The command "pinmode all" will print the pin mode for all pins.

ii. The CosaShell/CosaTelenetShell are mainly to demonstrate how to use the Cosa command line support (class Shell) but may also be used as debugging tools; check hardware connections, etc. Two new commands have been added to allow scanning of 1-Wire and I2C (OWI and TWI).

iii. Setting date/time and accessing the Cosa RTC timer. The command "date" may be used to display or set the current date/time.

2. New SPI function; clock()
The new static SPI function clock() will map from frequency to the SPI clock rate setting. This allows device drivers to be written independent of the MCU system clock setting and knowledge of the SPI rate command. A SPI device driver only needs to supply the max frequency required on the bus (for the connected device).

3. Boosting W5100 performance
The W5100 device driver uses the new interleaving SPI API (spi.transfer_start/next/await) so that memory access (load/store) can be executed in parallel with SPI transfers. This gives a performance improvement of 10-20%.

4. Bug fixes
a. Analog mux setting on Mega. Failed to read bandgap correctly after using higher analog pin numbers.
b. Improved W5100::Driver::flush() robustness when client or server disconnects.

Cheers!

« Last Edit: August 10, 2014, 02:50:58 am by kowalski » Logged

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

Next step in integrating Cosa Shell with Ethernet protocols; A HTTP Server that runs the command line handler.



This HTTP server is simply put together by filtering the HTTP query and passing it to the same command handler as in the previous examples (telnet and serial). Below is a snippet from the request handler:

Code:
void
WebServer::on_request(IOStream& page, char* method, char* path, char* query)
{
  static const char header[] __PROGMEM = ...
  static const char footer[] __PROGMEM = ...
  UNUSED(method);
  UNUSED(path);
  int res = -1;
  page << header;
  if (query != NULL) {
    char c;
    for (char* qp = query; (c = *qp) != 0; qp++)
      if (c == '&') *qp = ' ';
    res = shell.execute(query);
  }
  if (res != 0) page << PSTR("illegal query") << endl;
  page << footer;
}
https://github.com/mikaelpatel/Cosa/blob/master/examples/Ethernet/CosaShellWebServer/CosaShellWebServer.ino

The command line is the URL query where space between options and parameters are replaced with ampersand.

Cheers!
« Last Edit: August 10, 2014, 07:16:52 am by kowalski » Logged

Georgia, USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 81
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see the Teensy 2 is supported.  How about the Teensy 3.1?

Thanks,
Jim
Logged

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

I see the Teensy 2 is supported.  How about the Teensy 3.1?
Hi Jim!

I am sorry to say that the Teensy 3.1 is currently not supported. It is actually a totally different architecture and has much more resources (memory, DMA, etc) which would allow a very different approach to building small to medium scale embedded systems with both RTOS and library support.

Cosa is very much tailored for the AVR and very limited memory resources. On the bright side there is only a hand full classes that are accessing hardware registers etc. The Cosa HAL smiley.

I do have a couple of the Teensy 3.1 boards but have not yet come around to start playing with them. The Teensy 3.1 Arduino core could be an excellent source for kick-starting the porting of Cosa to ARM/SAM/Teensy 3.1.

Cheers!
Logged

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