How not to do a parcel tracking system

The SEUR tracking system in amazing in the wrong way.

I got a tracking number from a bike shop that dispatched a bike from spain to sweden.

Ok, so I go to http://www.seur.es (because http://seur.es didn’t work) and put my tracking number there. Nothing, the tracking number is not yet in the system. Disappointment number 1. But this is not the first time I see this, you get a tracking number and it takes a while until you can actually find it in the system so I’m OK.

After a couple of hours I try again and there it is. It only says “T1 EXPEDICION DOCUMENTADA” (expedition documented) not a very clear message I would say. I choose to believe that means the shipment has been recorded. The entry has a date but no time it just says 00:00:00. Disapointment number 2.

So the next morning I check again, it says the same thing. How come? Something should have happened with my bike, I’m sure it has moved to somewhere. So after digging in the FAQs of seur.es I find that if I want to track an international shipment I should use http://www.seurinternacional.com instead. Disappointement number 3. What?!? At least they could say so when I search in seur.es, they now it’s an international shipment, why don’t they tell me there that I’m looking in the wrong place? That I should go to seurinternacional instead.

We are in 2009 and they didn’t get this right yet.

At least now I know that the bike arrived to barcelona at 8:00 this morning.

Conceptronics CSATACOMBO is not a Hardware RAID card

As clearly stated in Linux SATA RAID FAQ the Conceptronics CSATACOMBO card based on VIA vt6421 chipset is not a Hardware RAID.

The CSATACOMBO is called a “fake raid“, “BIOS RAID” or “BIOS-assisted software RAID” that means that actually a driver at OS level is needed to get the RAID features (see more info about BIOS RAID at novell page).

And that’s why Linux (gparted for example) doesn’t recognize the RAID arrays created with CSATACOMBO because there’s no Linux driver to handle the proprietary BIOS RAID in CSATACOMBO.

You can always create a Sofware RAID.

Python support for SSL and HTTPS is not installed

I was getting “Python support for SSL and HTTPS is not installed” while trying to use Mercurial on Mac OS X 10.5 Leopard. I upgraded python to 2.5.2

sudo port upgrade python

and mercurial too (1.2.1)

sudo port -u upgrade mercurial

But that didn’t fix it. I’m glad that I found the solution on Twitter

Just do an

sudo port install py25-socket-ssl

Painting LabelWidgets on top of the ConnectionWidget - Netbeans Visual Library

I was fiddling with the Netbeans Visual Library again, trying to show a complex graph on screen and I run into a problem: There were so many connection in the graph that some widgets were hard to read because the ConnectionWidget arrows were printed over them.

LabelWidget hidden under ConnectionWidget

So I tried to I try to rearrange the order of my LayerWidgets to paint the LabelWidgets on top of ConnectionWidgets. A call to mainLayer.bringToFront() should be enough, but this is what I got when I tried that:

java.lang.IllegalStateException: Widget (org.netbeans.api.visual.widget.LabelWidget@10014f0) was not added into the scene
        at org.netbeans.api.visual.anchor.Anchor.getRelatedSceneLocation(Anchor.java:213)
        at org.netbeans.modules.visual.anchor.RectangularAnchor.compute(RectangularAnchor.java:111)
        at org.netbeans.modules.visual.router.DirectRouter.routeConnection(DirectRouter.java:65)
        at org.netbeans.api.visual.widget.ConnectionWidget.calculateRouting(ConnectionWidget.java:527)
        at org.netbeans.modules.visual.layout.ConnectionWidgetLayout.layout(ConnectionWidgetLayout.java:109)
        at org.netbeans.api.visual.widget.Widget.layout(Widget.java:1350)
        at org.netbeans.api.visual.widget.Widget.layout(Widget.java:1342)
        at org.netbeans.api.visual.widget.LayerWidget.layout(LayerWidget.java:86)
        at org.netbeans.api.visual.widget.Widget.layout(Widget.java:1342)
        at org.netbeans.api.visual.widget.Scene.layoutScene(Scene.java:312)
        at org.netbeans.api.visual.widget.Scene.validate(Scene.java:393)
        at org.netbeans.api.visual.widget.SceneComponent.addNotify(SceneComponent.java:92)
        at java.awt.Container.addImpl(Container.java:1039)
        at java.awt.Container.add(Container.java:896)
        at com.rubenlaguna.modules.mainmodule.GraphTopComponent.setDotFile(GraphTopComponent.java:80)
        at com.rubenlaguna.modules.mainmodule.DotOpenSupport.createCloneableTopComponent(DotOpenSupport.java:31)
        at org.openide.windows.CloneableOpenSupport.openCloneableTopComponent(CloneableOpenSupport.java:197)
        at org.openide.windows.CloneableOpenSupport$1.run(CloneableOpenSupport.java:98)
        at org.openide.util.Mutex.doEvent(Mutex.java:1335)
        at org.openide.util.Mutex.writeAccess(Mutex.java:452)
        at org.openide.windows.CloneableOpenSupport.open(CloneableOpenSupport.java:95)
        at org.openide.actions.OpenAction.performAction(OpenAction.java:81)
        at org.openide.util.actions.NodeAction$DelegateAction$1.run(NodeAction.java:589)
        at org.netbeans.modules.openide.util.ActionsBridge.doPerformAction(ActionsBridge.java:77)
        at org.openide.util.actions.NodeAction$DelegateAction.actionPerformed(NodeAction.java:585)
        at org.openide.explorer.view.TreeView$PopupSupport.mouseClicked(TreeView.java:1515)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
        at java.awt.Component.processMouseEvent(Component.java:6137)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
        at java.awt.Component.processEvent(Component.java:5899)
        at java.awt.Container.processEvent(Container.java:2023)
        at java.awt.Component.dispatchEventImpl(Component.java:4501)
        at java.awt.Container.dispatchEventImpl(Container.java:2081)
        at java.awt.Component.dispatchEvent(Component.java:4331)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3974)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3895)
        at java.awt.Container.dispatchEventImpl(Container.java:2067)
        at java.awt.Window.dispatchEventImpl(Window.java:2458)
        at java.awt.Component.dispatchEvent(Component.java:4331)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

So I posted a question on netbeans graph mailing list but the suggestions there didn´t resolved my problem.

After digging a little bit into the Visual Library source code I come up with a really easy solution. Just call mainLayer.bringToFront() AFTER the scene was painted for the first time on the screen. I should have tried that first!. The result shows LabelWidgets painted overt the ConnectionWidgets so the text in the LabelWidgets is always readable.

class GraphTopComponent extends CloneableTopComponent {
//.... omitted ....
  private showScene() {
        JComponent c = scene.createView();
        GraphLayout graphLayout = GraphLayoutFactory.createHierarchicalGraphLayout(scene, false);
        ForceDirectedLayout forceDirectedGraphLayout = new ForceDirectedLayout(scene);
        SceneLayout sceneGraphLayout = LayoutFactory.createSceneGraphLayout(scene, graphLayout);
        sceneGraphLayout.invokeLayout();
        this.forceDirectedSceneLayout = LayoutFactory.createSceneGraphLayout(scene, forceDirectedGraphLayout);
        jPanel1.removeAll();
        jPanel1.add(c);
        scene.bringMainLayerToFront();
  }
}
class DotGraphScene extends GraphScene.StringGraph {
//... omitted ...
    void bringMainLayerToFront() {
        mainLayer.bringToFront();
    }

}

LabelWidgets on top of ConnectionWidgets

Anchor will throw an IllegalStateException if the relatedWidget has no location in the scene. Those widget will not get a position until the LayerWidget that contains them is processed. So you keep the original order of the LayerWidgets until the scene is painted for the first time, by then all widgets have a location in the scene and then it’s posible to change the relative order of the LayerWidgets using LayerWidget.bringToFront().

The only problem with this approach is that is your are using a dynamic layout like me there is a chance that the layout changes the position of the LabelWidget by a noticiable amount and the Anchor will not be updated accordingly until the next iteration of the dynamic layout. Which lead to the artifact marked in red in the previous figure. This is only a real problem if your dynamic layout doesn’t stabilize or if is not very smooth.

NullPointerException in FontDesignMetrics$MetricsKey.init when using Netbeans Visual Library

If you’re getting a NullPointerException stacktrace like the one below while using the Netbeans Visual Library to create your own GraphScene, check that your adding your widgets propertly to scene. A good idea is to use LayerWidgets, declaring them in the constructor of your GraphScene:

mainLayer = new LayerWidget(this);
addChild(mainLayer);
connectionLayer = new LayerWidget(this);
addChild(connectionLayer);

and then add the widgets to those layers in attachNodeWidget and attachEdgeWidget:

    @Override
    protected Widget attachNodeWidget(String node) {
        LabelWidget w = new LabelWidget(this, node);
        w.setBorder(BORDER4);
        w.getActions().addAction(createSelectAction());
        w.getActions().addAction(createObjectHoverAction());
        w.getActions().addAction(ActionFactory.createMoveAction());
        this.mainLayer.addChild(w);
        return w;
    }

@Override
protected Widget attachEdgeWidget(String edge) {
    ConnectionWidget w = new ConnectionWidget(this);
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    this.connectionLayer.addChild(w);
    return w;
}

The stacktrace:

java.lang.NullPointerException
at sun.font.FontDesignMetrics$MetricsKey.init(FontDesignMetrics.java:199)
at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:267)
at sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:973)
at org.netbeans.api.visual.widget.LabelWidget.calculateClientArea(LabelWidget.java:260)
at org.netbeans.api.visual.widget.Widget.calculatePreferredBounds(Widget.java:1005)
at org.netbeans.api.visual.widget.Widget.getPreferredBounds(Widget.java:981)
at org.netbeans.modules.visual.graph.layout.HierarchicalLayout$BuildDatastructure.run(HierarchicalLayout.java:262)
at org.netbeans.modules.visual.graph.layout.HierarchicalLayout$AlgorithmPart.start(HierarchicalLayout.java:171)
at org.netbeans.modules.visual.graph.layout.HierarchicalLayout.performGraphLayout(HierarchicalLayout.java:206)
at org.netbeans.api.visual.graph.layout.GraphLayout.layoutGraph(GraphLayout.java:116)
at org.netbeans.api.visual.layout.LayoutFactory$1.performLayout(LayoutFactory.java:284)
at org.netbeans.api.visual.layout.SceneLayout$LayoutSceneListener.sceneValidated(SceneLayout.java:122)
at org.netbeans.api.visual.widget.Scene.validate(Scene.java:420)
at org.netbeans.api.visual.widget.SceneComponent.addNotify(SceneComponent.java:88)
at java.awt.Container.addImpl(Container.java:1062)
at java.awt.Container.add(Container.java:352)
...
...
...
at org.openide.windows.CloneableOpenSupport.openCloneableTopComponent(CloneableOpenSupport.java:197)
at org.openide.windows.CloneableOpenSupport$1.run(CloneableOpenSupport.java:98)
at org.openide.util.Mutex.doEvent(Mutex.java:1335)
at org.openide.util.Mutex.writeAccess(Mutex.java:452)
at org.openide.windows.CloneableOpenSupport.open(CloneableOpenSupport.java:95)
at org.openide.actions.OpenAction.performAction(OpenAction.java:81)
at org.openide.util.actions.NodeAction$DelegateAction$1.run(NodeAction.java:581)
at org.netbeans.modules.openide.util.ActionsBridge.doPerformAction(ActionsBridge.java:77)
at org.openide.util.actions.NodeAction$DelegateAction.actionPerformed(NodeAction.java:577)
at org.openide.explorer.view.TreeView$PopupSupport.mouseClicked(TreeView.java:1492)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
at java.awt.Component.processMouseEvent(Component.java:6129)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5891)
at java.awt.Container.processEvent(Container.java:2102)
at java.awt.Component.dispatchEventImpl(Component.java:4497)
at java.awt.Container.dispatchEventImpl(Container.java:2160)
at java.awt.Component.dispatchEvent(Component.java:4327)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4366)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4039)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3960)
at java.awt.Container.dispatchEventImpl(Container.java:2146)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4327)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:300)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:210)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:195)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:187)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Add Platform Sources using Netbeans Platform Manager

To be able to do Navigate ⇒ Go to Source on netbeans classes like TopComponent you need to link the sources to the Netbeans Plaform using the Netbeans Plaform Manager as explained in Hyperlinking to NetBeans API Sources.

Be sure to download the proper source zip from the netbeans download page, otherwise the Platform Manager won’t let you attach the source file to the platform (all invalid options are greyed out/dimmed):

Opening Favorites window at startup in a Netbeans Platform Application

After learning about the Favorites window in the NetBeans Platform Quick Start. I wanted to use it in an application of my own.

graphbrowser3

This easy task became more difficult that I though because I was getting random results, sometimes after a clean build I got the Favorites window open and sometimes not.

But let’s start from the beginning, I put my hands at work, it was just a matter of adding the Favorites module to the Netbeans Platform Application (app’s properties ⇒ Libraries ⇒ Platform Modules ⇒ platform9 ⇒ Favorites) and edit one of my modules layer.xml to override Windows2/Modes/explorer/favorites.wstcref. Just go to Important Files ⇒ XML Layer ⇒ this layer in context ⇒ Windows2 ⇒ Modes ⇒ explore ⇒ favorites.wstcref and replace

 <state opened="false" />

with

 <state opened="true" />

So the layer.xml in the module ended like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
<filesystem>
    <folder name="Windows2">
        <folder name="Modes">
            <folder name="explorer">
                <file name="favorites.wstcref" url="favoritesWstcref.xml"/>
            </folder>
        </folder>
    </folder>
</filesystem>

and the favoritesWstcref.xml file in my module look like this:

<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE tc-ref PUBLIC
          "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN"
          "http://www.netbeans.org/dtds/tc-ref2_0.dtd">
 
<tc-ref version="2.0">
    <module name="org.netbeans.modules.favorites/1" spec="1.1" />
    <tc-id id="favorites" />
    <state opened="true" />
</tc-ref>

But it didn’t work as expected sometimes after doing a clean & build the favorites didn’t open at startup. So I asked in the forums and I got a tip that help me to resolve the issue. It was a module loading order problem. But how do you set the module loading order, easy, just click on your module properties ⇒ Libraries ⇒ Add Dependency ⇒ Non-API module ⇒ Favorites.

brandingmoduleproperties

Adding a dependency with the Favorites modules will ensure that Favorites is loaded before your module and thus ensuring that you layer.xml changes will override the values set by Favorites module (and not the other way around).

Sudden voltage drop on MAX756

I got the MAX756 that I was waiting for from Futurlec. The idea was to implement the very same circuit that comes in the MAX756 datasheet. In my first try I got very strange results which I posted to lladyada forum hoping to get some advice on how to solve. Eventually I set up the circuit in another breadboard and got it working the way I expected or at least I thought so.

MAX756

Now I have the SMPS laid out on a breadboard. I’m powering this SMPS based on MAX756 with a 1.5V battery and I get 3.3V output with no load. If I connect a load (1led+220ohm) I still got 3.3V. That’s ok. I even connected three leds in parallel (24mA). Still working, I get a sound 3.3V reading in my DMM.

But when I connect this 3.3V output to my arduino project (mounted on a breadboard too) things change, and they change in a bad way. It seems to work perfectly for 5 or 6 seconds, 3.3V the green led mounted in the Arduino Pro Mini blinks as it should (because the sketch loaded does that) and the power red led in on and shining bright. But after 5 seconds the voltage drops from 3.3V to 1.7V, the red led still on but dimmed and the green led goes off. This lasts 1 sec maybe 2, and then the voltage goes up to 3.3V again. the arduino resets and the whole process begins again.

I don’t know what happening, but I decided to give up on the SMPS for a while. I will power my design using two coin cells and the LDO regulator already mounted in the Arduino Pro Mini. Less efficient but much easier to use.

I’ll come back to the SMPS when I have more time to investigate and read more about SMPS design and troubleshooting.

References

Adding C++ virtual methods in Visio

Amazing how difficult is to get C++ virtual methods in Visio .

visio drawing

visio drawing

High speed USB in a embedded design

I’m looking at how to do a USRP clone. After evaluating a little bit the Altera Cyclone FPGA development/starter kits I realized that I would need an extra USB controller like the original USRP has. Right now, I’m trying to figure out how to use the Cypress FX2 CY7C68013, together with the FPGA. The USRP FAQ on FX2 CY7C68013 has proven quite helpful, also the Design of a hardware platform for narrow-band Software Defined Radio applications” by Kalen Watermeyer .

So now I think I’m going to order a Cypress FX2 CY7C68013 breakout card and read a little bit more about the FX2 - FPGA interface using the GPIF on Kalen’s thesis and reading gnu radio source code (there are some clues on the FAQ about which source files to look first).

GPIF interface

GPIF interface

References: