0.9 closer and closer

January 20, 2014 Leave a comment

Some days ago we made Searduino work way better. Jearduino/Searduino only crashed every 2000 time. Way better than every second time. Still not really a sign of something working is it… and really hard to let go of 😉

After some more hours we found the problem…. Searduino (the simulator engine) may call the function callback after they’ve been closed (dlclose). Quite easy to fix and frustratingly obvious (as always) once you found the bug.

Now, with some ugly printf/println we’ve tested more. We tested for 20 hours and after 381,687 runs with:

  • load
  • run
  • halt
  • close

we got no crashed. The code is merged so we’re going to focus on regression tests. After that,iIt’s about time to release 0.9.

We’ll give the release a nickname since Henrik is in New Zealand while the release is made. 0.9 will be called “kiwi”….. if nothing really bad happens.

cheers

Advertisements
Categories: Uncategorized

Final tests of thread problem. Preparing for 0.9

January 10, 2014 Leave a comment

Jearduino (the Java GUI frontend to Searduino) is using JNI to load the Searduino (in practice the Arduino Simulator Engine). When doing this two techniques are in use:

Jearduino loads a dynamic library (dlopen), finds a symbol (dlsym) and then starts a new thread (pthread_create) using the symbol found. When the user requests the thread to stop calls to pthread_cancel and to dlclose are made (looks a bit different in git right now, so this refers to my (Henrik’s) local git repo.

Since the user (rightfully) expects the simulator to execute freshly built code rather than the code before the build the same amount of call to dlclose as to dlopen must be made. Why? – dlopen keeps a reference count and if the ref count is not zero it does not load the file but reuse the previously loaded file. Uh oh – so the user thinks  (I would at least) think that the new code is run but it isn’t. So we have written some code to make sure the latest code is actually loaded.

Ok, but what is the problem? ….get on with it you stupid bastard!!

Problem is that the pthread_cancel and the dlclose seemed to occasionally crash the program when occurring to closely in time. So a couple of sleep (usleep) has been added after the call to pthread_cancel. We all hate adding sleep but in this case it does not do any harm to the user – only to use as hackers. It seems to work though, so we’re keeping it. Will try to find a real solution – with no sleeps – later on.

So right now, one laptop is running tests since some hours ago. The tests are loading/running/closing code all the time… and so far 2249 runs with no crashes (compared to 1-2 runs before a crash before)….. will run the tests all night.

Yeah, some words about preparing. We’ve added quite a few features to make Searduino (in practice Jearduino) more user friendly. Once these tests pass it’s time to release 0.9 and reestablish contact with the nice Debian people since we think Searduino is good enough to put in there now.

/h

Categories: Uncategorized

New log window

January 6, 2014 Leave a comment

We’ve added a log window with a bigger textarea (with scrollbar). Screenshot here:

jearduino-log

Categories: Uncategorized

Arduino board build and upload is working

January 6, 2014 Leave a comment

It is now possible (only in git) to build for and upload to real Arduino boards.

Before release we will do a major code cleanup in the Java GUI. The information about the states are really scattered all over so before someone actually reads the code we will try to hide all traces.

 

 

Categories: Uncategorized

Searduino 0.8 released

January 4, 2014 Leave a comment

News in 0.8

In short:

Better integration with Arduino.

With this release it is possible to import an Arduino file in to the GUI Simulator (jearduino) and have the code automically built and loaded so you can run your Arduino code. The resulting C code is stored in ~/searduino/<ino-example>.

General changes:

Jearduino:

New menu items

  • Import Arduino examples (ino files)
    • Import an Arduino file which results in a Searduino project ready for use in simulator
  • Searduino projects
    • Work with directoris containing Searduino code
  • Build
    • when having a project loaded

Other GUI changes:

  • Tabbed paned
    • extra tab with logs from arduino sim engine
  • Manual
    • open manual in browser

New command line arguments:

  • –arduino-code <FILE> – loads <FILE> for use
  • –board <BOARD> – sets <BOARD> to use
  • –start – starts your code as soon as it is loaded

Stream simulator:

New command line arguments:

  • –searduino-project <di> – load searduino project dir

New programs:

  • bin/searduino-builder – to ease up builds
  • bin/searduino-stream.sh – wrapper for streamed simulator

Configuration:

  • share/searduino/settings – conf file for Searduino (logs etc)
  • share/searduino/functions – basic bash functions for scripts and wrappers

New implemented API functions:

  • none / not any

Bugs fixed:

  • Wrong month in logs

… and a screenshot

Jearduino 0.8

Categories: Uncategorized

Searduino 0.7 released

December 30, 2013 Leave a comment

Download

Source code dist:

Binary dist:

GNU/Linux

News in 0.7

General changes:

  • LCD Support
  • Available in Java extenstions, Stream simulator, Jearduino
  • NOT available in Python extension

Jearduino:

  • LCD Support
  • Pin types now shown as Combo boxes

New arguments:

    • –arduino-code <FILE> – loads <FILE> for use
    • –board <BOARD> – sets <BOARD> to use
    • –start – starts your code as soon as it is loaded

New implemented API functions:

Math:

  • randomSeed(unsigned int seed)
  • random(long max)
  • random(long min, long max)

Liquidcrystal:

  • LiquidCrystal
  • begin
  • clear
  • home
  • setCursor
  • write
  • print

Bugs fixed:

  • Fixed changing pin types and modes (Leaonardo board)
  • Many more
Categories: Uncategorized

Partial LCD Support in Searduino (not complete, but ready for use)

December 28, 2013 Leave a comment

About Searduino (short version): C/C++ interface to your Arduino boards, build stand alone program for your local computer, run your Arduino code in a simulator. (Longer About)

The added LCD Support means you can play around with LCDs (2×16 characters) just as you can with physical Arduinos. We’ve tried to fake the behavior of “LCD Keypad Shield For Arduino” [1]. For a normal user (that is someone who does not want to write a simulator by her self) nothing needs to be done – it should work.

“Not much of the API is done – why bother to write about it?” – you may wonder!

We chose to blog about it early since need your help – join us!! 

Status

Update (Dec 29, 2013): Current status can be found here)

The LiquidCrystal API[2] offers the following functions (followed by Searduino’s implementation status

LiquidCrystal() - ok
begin() - ok
clear() 
home()
setCursor() - ok
write() - Coming up next
print() - ok
cursor()
noCursor()
blink()
noBlink()
display()
noDisplay()
scrollDisplayLeft()
scrollDisplayRight()
autoscroll()
noAutoscroll()
leftToRight()
rightToLeft()
createChar()

How to use them with Searduino’s two simulators:

You can run the example[4] that’s in the git repo.

cd example/lcd-shield
make -f Makefile.lcd-shield clean shlib

You should have a shared lib (lcd-shield.so) that you can load in Jearduino.

searduino-jearduino.sh

or as a separate program (using the default LCD functions):

make -f Makefile.lcd-shield clean prog
./lcd-shield

Jearduino

Jearduino is the GUI simulator frontend of Searduino. If you download the latest git[3] it’s all there ready to use, with a separate Panel for LCD.

Stream

Stream is the text based simulator frontend of Searduino. If you download the latest git[2] it’s all there ready to use, with a stdout printout of each LCD write.

How to use them in your own simulator:

C

uint8_t seasim_register_lcd_cb(lcd_to_sim_callback_ptr cb);
where lcd_to_sim_callback_ptr is defined as
typedef void    (*lcd_to_sim_callback_ptr)    (const char* str1, const char*str2);
so an example callback could look like this:
void
lcd_callback(const char *str1, const char *str2)
{
 printf ("LCD_CALLACK() LCD[0]: %s\n" , str1);
 printf ("LCD_CALLACK() LCD[1]: %s\n" , str2);
 fflush(stdout);  /*  MIND YOU, IS FLUSH REALLY NEEDED!!! */ 
}

Java

Implement:

SearduinoObserver

Call:

registerLCDCallback(this);

Add a callback, typically like this:

public void handleLCDEvent(String row1, String row2)
 {
 System.out.println("EVENT: LCD MESSAGE-------------> " + row1 + " " + row2 );
}

Python

Not implemented yet

… and if you’ve read this far you might as well join us

[1] http://www.dfrobot.com/index.php?route=product/product&product_id=51#.Ur1i1pCJDAQ

[2] http://arduino.cc/en/Reference/LiquidCrystal

[3] http://git.savannah.gnu.org/gitweb/?p=searduino.git;a=summary

[4] http://git.savannah.gnu.org/gitweb/?p=searduino.git;a=blob_plain;f=example/lcd-shield/lcd-shield.cpp;hb=HEAD

Categories: Uncategorized