<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Slashdev</title>
	<atom:link href="http://www.slashdev.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.slashdev.ca</link>
	<description>Hardware, software, and just general tinkering</description>
	<lastBuildDate>Fri, 29 Jan 2010 04:30:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fixing Sigtool &#8211; Again</title>
		<link>http://www.slashdev.ca/2010/01/28/fixing-sigtool-again/</link>
		<comments>http://www.slashdev.ca/2010/01/28/fixing-sigtool-again/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 03:40:56 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=298</guid>
		<description><![CDATA[A year or so ago I wrote out some instructions detailing how to make SignatureTool.jar work in Unix type systems. Soon after I got word that somewhere around JDE 4.6 or JDE 4.7, RIM actually fixed the mistake in the sigtool.  Sadly they missed one.
If you attempt to sign a .cod file larger than [...]]]></description>
			<content:encoded><![CDATA[<p>A year or so ago I wrote out some instructions detailing <a href="/2008/03/16/using-sigtool-in-linux/">how to make SignatureTool.jar work</a> in Unix type systems. Soon after I got word that somewhere around JDE 4.6 or JDE 4.7, RIM actually fixed the mistake in the sigtool.  Sadly they missed one.</p>
<p>If you attempt to sign a <tt>.cod</tt> file larger than 64KB (ie: contains sibling files or child files or whatever files) then you will likely get a file created in your current working directory that looks something like <tt>kd8m34jkf/my_lame_app-1.cod</tt>.  When you load the file to the device it will result in an error of some sort.  The fix for this is relatively simple.  Read on for the details.</p>
<p><span id="more-298"></span></p>
<h2>Edit class file</h2>
<p>Go back and read my <a href="/2008/03/16/using-sigtool-in-linux/">other post</a> for instructions on extracting the jar file and for packaging it up again.  I&#8217;m going to leave out some details here since they are covered previously.</p>
<p>Note: this is based on the SignatureTool.jar file from JDE 4.7.  I have not verified that this procedure is the same for other versions of the JDE.</p>
<p>We will use good old <a href="http://classeditor.sourceforge.net/">ClassEditor</a> again.  Open <tt>q.class</tt> and change string constant at index 253 from a back slash to a forward slash.</p>
<div id="attachment_307" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.slashdev.ca/wp-content/uploads/2010/01/2010-01-28-233337_800x600_scrot.png"><img src="http://www.slashdev.ca/wp-content/uploads/2010/01/2010-01-28-233337_800x600_scrot-400x300.png" alt="Edit string constant at index 253 in q.class" title="2010-01-28-233337_800x600_scrot" width="400" height="300" class="size-medium wp-image-307" /></a><p class="wp-caption-text">Edit string constant at index 253 in q.class</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2010/01/28/fixing-sigtool-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Signing Servers Down Again</title>
		<link>http://www.slashdev.ca/2010/01/28/signing-servers-down-again/</link>
		<comments>http://www.slashdev.ca/2010/01/28/signing-servers-down-again/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 03:29:54 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=292</guid>
		<description><![CDATA[It&#8217;s 10:00pm EST, Jan. 28th and RIM&#8217;s signing servers have been down for the last sixty minutes. This wouldn&#8217;t be such an issue if the rest of the BlackBerry development tool suite wasn&#8217;t such a steaming pile of crap!  Quite literally the only component that works &#8211; is the compiler.
The simulator doesn&#8217;t sim and [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s 10:00pm EST, Jan. 28th and RIM&#8217;s signing servers have been down for the last sixty minutes. This wouldn&#8217;t be such an issue if the rest of the BlackBerry development tool suite wasn&#8217;t such a steaming pile of crap!  Quite literally the only component that works &#8211; is the compiler.</p>
<p>The simulator doesn&#8217;t sim and the signing tool doesn&#8217;t sign.  These two issues cause a serious problem.</p>
<p>First the simulator.  If you take an OS 4.3.1 simulator and a device also running OS 4.3.1 the two will behave very differently in a few subtle, but important ways.  My gripe is localized to the <a href="http://www.blackberry.com/developers/docs/4.3.0api/javax/microedition/media/package-frame.html">mmapi</a> api (handles audio/video playback).  Long story short, the simulator can&#8217;t be trusted so we have to debug device/OS idiosyncrasies on the device itself.</p>
<p>But hold on a second.  The signing servers aren&#8217;t working so I <strong>can&#8217;t</strong> debug on the device in all it&#8217;s developer friendly glory with lack of usable debugger and lack of even something as simple as a means to read text written to <strong>freaking</strong> <a href="http://en.wikipedia.org/wiki/Standard_output">standard output</a>!</p>
<p>Thank you RIM!  Thank you for wasting my valuable time.  Thank you for reminding me that no amount of money can justify writing software for this platform any longer.</p>
<p>(10:30, signing servers still not working)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2010/01/28/signing-servers-down-again/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introducing jQTemplate</title>
		<link>http://www.slashdev.ca/2009/06/16/introducing-jqtemplate/</link>
		<comments>http://www.slashdev.ca/2009/06/16/introducing-jqtemplate/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 17:32:12 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=261</guid>
		<description><![CDATA[Some time ago I started a little experiment to see what this whole &#8220;Web 2.0&#8243; development thing was all about.  The goal of the experiment was to develop a simple application without the help of any server side web framework, and instead use JSON as a data interchange format.  All HTML, CSS, and [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_264" class="wp-caption aligncenter" style="width: 380px"><img src="http://www.slashdev.ca/wp-content/uploads/2009/06/jqtemplate.png" alt="jQTemplate in action" title="jqtemplate" width="370" height="220" class="size-full wp-image-264" /><p class="wp-caption-text">jQTemplate in action</p></div>
<p>Some time ago I started a little experiment to see what this whole <a href="http://git.slashdev.ca/linkdb/">&#8220;Web 2.0&#8243; development</a> thing was all about.  The goal of the experiment was to develop a simple application without the help of any server side web framework, and instead use <a href="http://json.org/">JSON</a> as a data interchange format.  All HTML, CSS, and JavaScript should be cleanly separated.</p>
<p>Cleanly separating the HTML from the JavaScript posed a challenge and thus <a href="/jqtemplate">jQTemplate</a> was born.  The concept is simple: write snippets of HTML code with annotations (in the form of special XML attributes) that can be used to transform the snippet into elements in the DOM.</p>
<p>The result I think is actually quite nice, and I love me some pretty code!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2009/06/16/introducing-jqtemplate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NES USB Gamepad</title>
		<link>http://www.slashdev.ca/2009/04/12/nes-usb-gamepad/</link>
		<comments>http://www.slashdev.ca/2009/04/12/nes-usb-gamepad/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 06:25:21 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[Make]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=228</guid>
		<description><![CDATA[This is mainly a show and tell post.  What we have here is a NES controller that has been converted into a USB HID device.  This means it can be connected to a computer without installing any drivers (Linux, Mac OS X, and Windows XP).
The circuit, PCB design, and firmware for the Atmega8 [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_229" class="wp-caption alignleft" style="width: 310px"><img src="http://www.slashdev.ca/wp-content/uploads/2009/04/img_1733-300x225.jpg" alt="Assembled controller" title="nes_usb" width="300" height="225" class="size-medium wp-image-229" /><p class="wp-caption-text">Assembled controller</p></div>
<p>This is mainly a show and tell post.  What we have here is a NES controller that has been converted into a USB HID device.  This means it can be connected to a computer without installing any drivers (Linux, Mac OS X, and Windows XP).</p>
<p>The circuit, PCB design, and firmware for the Atmega8 micro-controller are courtesy of <a href="http://www.raphnet.net/electronique/snes_nes_usb/index_en.php">Raphaël Assénat</a>.  His website is a veritable cornucopia of awesome circuitry.  And the best part?  All of his work is fully documented and provided for use under the GPL license where applicable.</p>
<p>Now the show part is over, time for the tell.</p>
<p><span id="more-228"></span></p>
<h2>PCB Fabrication</h2>
<p>First I would like to say I am no electrical engineer.  I love building circuits and playing with micro-controllers but I have very little knowledge of the theory behind a circuit.  That said, I learned a few things during this project that I would like to share.</p>
<p>The first lesson: surface mount PCB&#8217;s are painful!  The actual soldering isn&#8217;t so bad.  Search <a href="http://www.youtube.com">YouTube</a> for <em>surface mount soldering</em> and you will get a ton of great instructional videos.</p>
<div id="attachment_233" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.slashdev.ca/wp-content/uploads/2009/04/img_1728.jpg"><img src="http://www.slashdev.ca/wp-content/uploads/2009/04/img_1728-300x225.jpg" alt="Isn&#039;t it cute!" title="nes_usb_circuit" width="300" height="225" class="size-medium wp-image-233" /></a><p class="wp-caption-text">Isn't it cute!</p></div>
<p>The real issue for me was fabricating the PCB.  I usually use the <a href="http://www.mgchemicals.com/products/416k.html">photo fabrication</a> method but one of the tiny traces would get burned off every time.  It&#8217;s poossible through some trial and error with expossure time I might have been able to get this to work but each failure is expensive!  Pre-sensitized copper clad can cost up to $10 per sheet (aprox. 6&#215;6 inches).</p>
<p>I ended up using the <a href="http://www.fullnet.com/~tomg/gooteepc.htm">toner transfer</a> method which I found tedious at best.  I had to experiment several times over with different laser printers, print settings, iron temperature, iron pressure, and ironing time.  Too many variables!  That said, failures are cheep.  If the artwork did not stick to the copper correctly, just clean the copper and try again.</p>
<h2>Atmega8 Micro-controller</h2>
<p>I actually built this circuit a few months ago.  After assembling the circuit and connecting the ICSP programmer I successfully:</p>
<ol>
<li>flashed the firmware</li>
<li>burned the fuses</li>
</ol>
<p>Then I connected the USB cable to the computer but the device failed to register!  I was so frustrated that after all of that work, I just stuck the project on the shelf and forgot about it.</p>
<p>Recently I was working with another Atmega8 based board when I realized my error.  See, when you receive your AVR chip from the factory it is configured to use an internal oscilator.  This internal osilator circuit tells the AVR what speed to run at (eg: 1 MHz).</p>
<p>The <a href="http://www.engbedded.com/fusecalc">fuses</a> are a set of bytes in the flash that determine how the chip operates.  One of the fuse settings tell the chip to ignore the internal osilator circuit and look for an external one.  The NES USB board is an example of a circuit that uses an external oscilator in the form of a crystal.</p>
<p>Beside the crystal are two capacitors and here is where I went wrong.  These capacitors are 27pF on Raphaël&#8217;s circuit but I used a through hole crystal instead of the surface mount variety and these capacitor values are specific to the crystal!  You can find the appropriate values in the crystals datasheet, in my case 18pF.</p>
<p>This explains why I was able to flash the firmware and the fuses.  Once the fuses where flashed the AVR chip expected to have a working external oscilator but due to incorrect capacitors the external oscilator couldn&#8217;t function and neither could the chip.  After replacing the capacitors the circuit sprang to life.</p>
<p>So in closing I hope this helps another noob like me out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2009/04/12/nes-usb-gamepad/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Notch in the Cross Platform Blackberry Development Belt</title>
		<link>http://www.slashdev.ca/2009/03/11/a-notch-in-the-cross-platform-blackberry-development-belt/</link>
		<comments>http://www.slashdev.ca/2009/03/11/a-notch-in-the-cross-platform-blackberry-development-belt/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 14:03:06 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=212</guid>
		<description><![CDATA[In a previous post I listed 4 key items needed for BlackBerry development:

Rapc compiler
Signature tool
Simulator
Javaloader

At the time of writing the first two worked fine.  The third, Simulator, is if&#8217;y at best.  And the fourth was just not possible.
Until now.  In late December, a saviour by the name of Nicolas Vivien dropped by [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/">previous post</a> I listed 4 key items needed for BlackBerry development:</p>
<ol>
<li>Rapc compiler</li>
<li>Signature tool</li>
<li>Simulator</li>
<li>Javaloader</li>
</ol>
<p>At the time of writing the first two worked fine.  The third, Simulator, is <a href="http://www.slashdev.ca/2008/03/27/blackberry-simulator-in-linux-sort-of">if&#8217;y at best</a>.  And the fourth was just not possible.</p>
<p>Until now.  In late December, a saviour by the name of Nicolas Vivien dropped by the <a href="http://www.netdirect.ca/software/packages/barry/">barry</a> mailing list to let everyone know that he was hard at work on reverse engineering the Javaloader USB protocol.  Within a few weeks he had developed a proof of concept that enabled users to load cod files to the BlackBerry.</p>
<p>Since then several developers (including myself) have chipped in to implement all of the crucial aspects of the Javaloader needed for day-to-day use.</p>
<p><span id="more-212"></span></p>
<h2>Which Commands are Supported?</h2>
<ul>
<li>list modules on handheld, including siblings</li>
<li>get handheld info</li>
<li>load one or more cod files onto the handheld</li>
<li>save one or more cod files from the handheld</li>
<li>erase cod files from the handheld</li>
<li>dump the eventlog</li>
<li>clear the eventlog</li>
<li>get screenshot of the handheld and save as bmp</li>
<li>set time on the handheld</li>
<li>wipe the applications and/or file system on the handheld</li>
</ul>
<p>As you can see, most of the important stuff is already finished.  And more is being added all the time.</p>
<h2>I&#8217;ve Heard Enough&#8230; Gimme, Gimme, Gimme!</h2>
<p>The Javaloader is slated to be included in the next release of Barry; version 0.15.  If you would like to test it right now, you&#8217;ll need to compile from source or find a binary package for your OS/distro.</p>
<p>Here are some instructions for <a href="http://www.netdirect.ca/software/packages/barry/cvs.php">compiling from source</a>.  If you get stuck, someone on the <a href="http://sourceforge.net/mail/?group_id=153722">mailing list</a> might be able to lend a hand.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2009/03/11/a-notch-in-the-cross-platform-blackberry-development-belt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bug Fixes &#8211; Arduino LCD Library</title>
		<link>http://www.slashdev.ca/2008/09/19/bug-fixes-arduino-lcd-library/</link>
		<comments>http://www.slashdev.ca/2008/09/19/bug-fixes-arduino-lcd-library/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 02:26:14 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[Arduino]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=200</guid>
		<description><![CDATA[Just a quick update on the Arduino LCD Library (bring it to version 0.3).  I have worked many hours to iron out all the bugs in the code that checks the LCD modules busy flag.  This is the part of the LCD modules controller that tells the arduino it&#8217;s in the middle of [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick update on the <a href="arduino-lcd-library">Arduino LCD Library</a> (bring it to version 0.3).  I have worked many hours to iron out all the bugs in the code that checks the LCD modules busy flag.  This is the part of the LCD modules controller that tells the arduino it&#8217;s in the middle of an internal operation.</p>
<p>Hopefully this fixes the sporadic behavior people have reported with their LCD&#8217;s.  It certainly fixes the problem with the two LCD&#8217;s I have tested.</p>
<p>I also added a <a href="http://svn.slashdev.ca/arduino/Lcd/trunk/ref/lcd_arduino.pdf">schematic</a> to the package.  It just outlines where to connect VCC, GND and where to put the 10K pot.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/09/19/bug-fixes-arduino-lcd-library/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Lean Mean Mediacenter Machine</title>
		<link>http://www.slashdev.ca/2008/08/11/lean-mean-mediacenter-machine/</link>
		<comments>http://www.slashdev.ca/2008/08/11/lean-mean-mediacenter-machine/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 22:19:34 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=131</guid>
		<description><![CDATA[A short time ago Handbrake began to ship with default encoding settings for the &#8220;Normal&#8221; profile using 2-pass h264 encoding.  Sadly my XBox and XBMC just weren&#8217;t up to the task of decoding all those fancy h264 bits in software anymore.
Naturally instead of adjusting the encoding parameters, I decided to begin the hunt for [...]]]></description>
			<content:encoded><![CDATA[<p>A short time ago <a href="http://handbrake.fr/">Handbrake</a> began to ship with default encoding settings for the &#8220;Normal&#8221; profile using 2-pass h264 encoding.  Sadly my <a href="xbox-remote-onoff">XBox</a> and <a href="http://xbmc.org/">XBMC</a> just weren&#8217;t up to the task of decoding all those fancy h264 bits in software anymore.</p>
<p>Naturally instead of adjusting the encoding parameters, I decided to begin the hunt for a new video player&#8230; oh and it has to be cheaper than that <a href="http://www.apple.com/appletv/">AppleTV</a> thing since it does h264.  It also has to be similarly quiet, power efficient, and small.</p>
<div id="attachment_141" class="wp-caption alignleft" style="width: 310px"><a href="http://www.slashdev.ca/wp-content/uploads/2008/07/finished_case.jpg"><img src="http://www.slashdev.ca/wp-content/uploads/2008/07/finished_case-300x167.jpg" alt="Not quite an AppleTV" title="finished_case" width="300" height="167" class="size-medium wp-image-141" /></a><p class="wp-caption-text">Not quite an Apple TV</p></div>
<p>Well this is the result.  It&#8217;s a bit bigger than an AppleTV but it&#8217;s certainly quiet and power efficient.  And I actually quite like the look of it.</p>
<p><br style="clear: both" /><br />
<span id="more-131"></span></p>
<h2>Hardware</h2>
<div id="attachment_143" class="wp-caption alignright" style="width: 160px"><a href="http://www.slashdev.ca/wp-content/uploads/2008/07/hardware.jpg"><img src="http://www.slashdev.ca/wp-content/uploads/2008/07/hardware-150x112.jpg" alt="The beginnings of a mediacenter pc" title="Hardware" width="150" height="112" class="size-thumbnail wp-image-143" /></a><p class="wp-caption-text">The beginnings of a mediacenter pc</p></div>
<p>D201GLY2TA MiniITX board, 1GB Kingston DDR2 667MHz, picoPSU 120W, Transcend 4GB x266 CF, and SAT2CF by startech.com.  Board, PSU/AC-DC converter came from <a href="http://www.mini-box.com">mini-box.com</a>, the memory and CF card from <a href="http://www.canadacomputers.com">canadacomputers.com</a> and the CF-SATA adaptor from <a href="http://www.ncix.com">ncix.com</a>.  Cost breakdown:</p>
<p><br style="clear: both" /></p>
<table>
<tr>
<th>Item</th>
<th>Cost</th>
<th>Comments</th>
</tr>
<tr>
<td>D201GLY2TA</td>
<td>$75.00</td>
<td>crappy frackin BIOS, not very Linux friendly&#8230; but it&#8217;s CHEAP!</td>
</tr>
<tr>
<td>picoPSU-120 power kit</td>
<td>$54.95</td>
<td>small, efficient, awesome&#8230; nuff said</td>
</tr>
<tr>
<td>CF200 IDE to CF adaptor</td>
<td>$9.50</td>
<td>BIOS is garbage, or the adaptor sucks&#8230; needless to say $10 down the crap shoot</td>
</tr>
<tr>
<td>1GB Memory</td>
<td>$29.99</td>
<td>it works</td>
</tr>
<tr>
<td>Trancend 4GB CF</td>
<td>$51.99</td>
<td>also, just works</td>
</tr>
<tr>
<td>SAT2CF</td>
<td>$38.04</td>
<td>slooooooow, as frack!  but so far not much of an issue</td>
</tr>
</table>
<p>Grand total including taxes, shipping and brokerage fees&#8230; aprox. $370 CDN.  Mother, %$*#!  That&#8217;s way more than the AppleTV.  Oh well, at least I didn&#8217;t have to give Apple Inc. any more of my hard earned money and this thing <strong>should</strong> be much more customizable&#8230; right?  Read on for details of the software.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/08/11/lean-mean-mediacenter-machine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MenuItem Demystified</title>
		<link>http://www.slashdev.ca/2008/05/07/menuitem-demystified/</link>
		<comments>http://www.slashdev.ca/2008/05/07/menuitem-demystified/#comments</comments>
		<pubDate>Wed, 07 May 2008 22:44:37 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=130</guid>
		<description><![CDATA[I&#8217;ve always been a bit confused as to what exactly the parameters to the MenuItem constructor do.  Common practise for me, and others I assume, is to simply ignore the ordinal and priority parameters and override the Screen.makeMenu method to explicitly define order.
While this is effective, it has a few caveats:

makeMenu gets messy
separators must [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been a bit confused as to what exactly the parameters to the <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/MenuItem.html#MenuItem(java.lang.String,%20int,%20int)">MenuItem</a> constructor do.  Common practise for me, and others I assume, is to simply ignore the ordinal and priority parameters and override the <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/Screen.html#makeMenu(net.rim.device.api.ui.component.Menu,%20int)">Screen.makeMenu</a> method to explicitly define order.</p>
<p>While this is effective, it has a few caveats:</p>
<ul>
<li>makeMenu gets messy</li>
<li>separators must be added explicitly</li>
<li>doesn&#8217;t play nice with context menu items added by framework</li>
</ul>
<p><span id="more-130"></span></p>
<h1>Well what does the API say?</h1>
<p>The obvious first place to look is the API documentation right?  OK, lets have a look at the class description and constructor parameters.</p>
<p><em>Each item has an ordinal specifying the sort order within the menu, and a priority specifying which one should be the default. A lower value indicates a higher priority.</em></p>
<ul>
<li>ordinal &#8211; Ordering parameter, lower values are placed closer to the top of the menu screen.</li>
<li>priority &#8211; The priority of the menu item. A lower value indicates a higher priority, conversely a higher value indicates a lower priority.</li>
</ul>
<p>Ordinal seems pretty straight forward.  But what relation (if any) does this have to separator placement?  And what if I want my menu items be placed <strong>below</strong> the context menu items of the fields on the screen?  What should my ordinal value be then?</p>
<p>The priority from what I can tell just determines the likelihood the menu item will be picked as the default.  Lower values indication higher priority and higher values a lower priority.</p>
<h1>Verdict</h1>
<p>Here&#8217;s a summary first, because the details are rather dry (skip them if you like):</p>
<ul>
<li>ordinal values < 10,000 are placed above context items</li>
<li>ordinal values >= to 300,000 are placed below context items</li>
<li>ordinal values with a difference larger than 100,000 have separators between them</li>
<li>use priority values >= 1000 play nice with context item priorities</li>
</ul>
<p>Using a basic sample containing a couple fields and a <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/MenuItem.html#getPrefab(int)">prefab</a> save menu item, I printed the ordinal ordinal and priority of each menu item in the menu generated by the MainScreen class (see source code at the end of the article).</p>
<p>Field context menu items have an ordinal somewhere in the neighbourhood of 10,000 to 200,000.  The prefab menu item for save has an ordinal around 300,000.  And based on the ordinal from the save menu item, it&#8217;s probably safe to assume that to place your menu items below context items, 300,000 is the magic number.</p>
<p>To have separators automagically placed between menu items, simply use an ordinal value at least 100,000 greater than the previous menu item.</p>
<p>Context menu items seem to have a priority value in the range of 100 to 500.  The prefab menu item has a priority of 1000 so I&#8217;m guessing this is an appropriate value for most menu items.</p>
<h1>MainScreen &#8211; Cause I&#8217;m Lazy</h1>
<p>The <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/container/MainScreen.html">MainScreen</a> class has a method <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/container/MainScreen.html#addMenuItem(net.rim.device.api.ui.MenuItem)">addMenuItem</a>. The documentation for this method reads:</p>
<p><em>A main screen brings up a menu by default when Screen.onMenu(int) is invoked. If the makeMenu(net.rim.device.api.ui.component.Menu, int) method is not overridden, it will add these menu items to the menu. The close menu item is added by default.</em></p>
<p>So as long as the ordinal and priority values are set appropriately, you don&#8217;t need to bother with the makeMenu method override at all!  Right?</p>
<p>Well there is one gotcha; MainScreen adds <strong>all</strong> all of the menu items to the menu.  If you need to omit items from the menu resulting from the trackball press, then you will have to add these items exclusively in the makeMenu method.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> MyScreen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   addMenuItem<span style="color: #009900;">&#40;</span>_saveMenuItem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #666666; font-style: italic;">// makeMenu will handle adding this now</span>
   <span style="color: #666666; font-style: italic;">//addMenuItem(_deleteMenuItem);</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> makeMenu<span style="color: #009900;">&#40;</span><span style="color: #003399;">Menu</span> menu, <span style="color: #000066; font-weight: bold;">int</span> instance<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">makeMenu</span><span style="color: #009900;">&#40;</span>menu, instance<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// add delete menu item when NOT making context menu (trackball-click)</span>
   <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> instance <span style="color: #339933;">!=</span> <span style="color: #003399;">Menu</span>.<span style="color: #006633;">INSTANCE_CONTEXT</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      menu.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>_deleteMenuItem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h1>Sample Code</h1>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.MenuItem</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.UiApplication</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.component.EditField</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.component.Menu</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.component.ObjectChoiceField</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.container.MainScreen</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Hello <span style="color: #000000; font-weight: bold;">extends</span> UiApplication <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">public</span> Hello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      MainScreen screen <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MainScreen<span style="color: #009900;">&#40;</span>MainScreen.<span style="color: #006633;">DEFAULT_MENU</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> makeMenu<span style="color: #009900;">&#40;</span><span style="color: #003399;">Menu</span> menu, <span style="color: #000066; font-weight: bold;">int</span> instance<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">makeMenu</span><span style="color: #009900;">&#40;</span>menu, instance<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span>, len<span style="color: #339933;">=</span>menu.<span style="color: #006633;">getSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>len<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #003399;">MenuItem</span> item <span style="color: #339933;">=</span> menu.<span style="color: #006633;">getItem</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DEBUG &quot;</span> <span style="color: #339933;">+</span> item.<span style="color: #006633;">getOrdinal</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
                     <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> item.<span style="color: #006633;">getPriority</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> item<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
      screen.<span style="color: #006633;">addMenuItem</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">MenuItem</span>.<span style="color: #006633;">getPrefab</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">MenuItem</span>.<span style="color: #006633;">SAVE_CLOSE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      screen.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> EditField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Edit: &quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      screen.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ObjectChoiceField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Choice: &quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;1&quot;</span>, <span style="color: #0000ff;">&quot;2&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      pushScreen<span style="color: #009900;">&#40;</span>screen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">new</span> Hello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">enterEventDispatcher</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/05/07/menuitem-demystified/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Simulator in Linux &#8211; Slightly More Reliable</title>
		<link>http://www.slashdev.ca/2008/04/10/simulator-in-linux-slightly-more-reliable/</link>
		<comments>http://www.slashdev.ca/2008/04/10/simulator-in-linux-slightly-more-reliable/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 03:20:38 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/2008/04/10/simulator-in-linux-slightly-more-reliable/</guid>
		<description><![CDATA[
Debug session with eclipse in Linux

Disclaimer: I am not an expert with wine nor have I ever claimed to be.  But if you setup an override for the msxml dll it seems as though the BlackBerry simulator is a bit more reliable in Linux.  In fact, the JDWP seems to actually work for [...]]]></description>
			<content:encoded><![CDATA[<div class="imageframe imgalignleft" style="width:300px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/04/debug-blackberry-linux.png" title="Debug session with eclipse in Linux"><img src="http://www.slashdev.ca/wp-content/uploads/2008/04/debug-blackberry-linux.thumbnail.png" width="300" height="187" alt="Debug session with eclipse in Linux" /></a>
<div class="imagecaption">Debug session with eclipse in Linux</div>
</div>
<p>Disclaimer: I am not an expert with <a href="http://www.winehq.org">wine</a> nor have I ever claimed to be.  But if you setup an override for the msxml dll it seems as though the BlackBerry simulator is a bit more reliable in Linux.  In fact, the JDWP seems to actually work for debugging  your applications.</p>
<p><br style="clear: both;"/><br />
<span id="more-124"></span></p>
<h1>Fix JDWP</h1>
<p>First you need to fix the JDWP.  I outlined the steps required to do this in my last article about <a href="/2008/03/27/blackberry-simulator-in-linux-sort-of">running the simulator in Linux</a>.</p>
<h1>DLL Overrides</h1>
<p>Copy the DLL files from a Windows box.  Again, I actually have no idea what I&#8217;m doing so I just went and copied all the DLL&#8217;s named <strong><tt>msxml*</tt></strong> from <tt>C:\WINDOWS\system32</tt> to my local wine directory <tt>~/.wine/drive_c/windows/system32</tt>.  It&#8217;s probably not necessary to copy all of them, but I don&#8217;t think it will hurt anything either.</p>
<p>Start up <tt>winecfg</tt> and select the <em>Libraries</em> tab.  Type <em>msxml3</em> in the <em>New override for library:</em> field and click Add.</p>
<div style="text-align: center;">
<div class="imageframe imgaligncenter" style="width:219px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/04/winecfg-linux.png" title="Winecfg with dll override"><img src="http://www.slashdev.ca/wp-content/uploads/2008/04/winecfg-linux.thumbnail.png" width="219" height="300" alt="Winecfg with dll override" /></a>
<div class="imagecaption">Winecfg with dll override</div>
</div>
</div>
<p>Start the JDWP and connect to it from your favorite IDE and watch the madness ensue.  Now I have not tested this thoroughly but my first couple of tries seem to work well.  So well in fact that I might event be able to ditch the VM running windows for debugging.  As always, <a href="http://en.wiktionary.org/wiki/your_mileage_may_vary">YMMV</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/04/10/simulator-in-linux-slightly-more-reliable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BlackBerry Development Using Linux</title>
		<link>http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/</link>
		<comments>http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 23:43:54 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/</guid>
		<description><![CDATA[Now this process isn&#8217;t 100% ideal.  If you are an experienced developer you probably already know you need four key components.

Rapc compiler
Signature tool
Simulator
Javaloader

The first two components works fabulously in Linux.  The second (signature tool) needs a kick in the pants to work (shame shame shame!).
The third is hit or miss when using Wine. [...]]]></description>
			<content:encoded><![CDATA[<p>Now this process isn&#8217;t 100% ideal.  If you are an experienced developer you probably already know you need four key components.</p>
<ol>
<li>Rapc compiler</li>
<li>Signature tool</li>
<li>Simulator</li>
<li>Javaloader</li>
</ol>
<p>The first two components works fabulously in Linux.  The second (signature tool) needs a <a href="/2008/03/16/using-sigtool-in-linux">kick in the pants</a> to work (shame shame shame!).</p>
<p>The third is <a href="/2008/03/27/blackberry-simulator-in-linux-sort-of">hit or miss</a> when using <a href="http://www.winehq.org/">Wine</a>.  So a less painful option is to put windows in a virtual machine and run the simulator there (more on that later).</p>
<p>And the fourth I just can&#8217;t get past.  There is the <a href="http://sourceforge.net/projects/barry">barry project</a> which has made impressive progress in the last few months and lists javaloader support as on the roadmap for milestone 4.  RIM, if you have any sympathy for us non-windows users show these guys some love and <a href="https://lists.sourceforge.net/lists/listinfo/barry-devel">send them</a> some specs for heaven sakes!</p>
<p>This article presents the basics for compiling, signing, and debugging BlackBerry applications with Linux.</p>
<p><span id="more-113"></span></p>
<h1>Rapc Compiler</h1>
<p>First you need a copy of the JDE or the JDE components package.  In my last <a href="/2008/03/27/blackberry-simulator-in-linux-sort-of">article</a> I covered a method of extracting the install packages distributed by RIM, but if you have access to a Windows box copying the installed JDE works just fine too.</p>
<p>The rapc compiler needs two external commands:</p>
<ol>
<li>Java Compiler (javac)</li>
<li>Preverification Tool (preverify)</li>
</ol>
<p>Install the Sun JDK to get javac:</p>
<p><code>sudo apt-get install sun-java5-jdk</code></p>
<p>The preverify command can be obtained by downloading the <a href="http://java.sun.com/products/sjwtoolkit/download.html">Sun WTK</a>.</p>
<p><code>chmod +x sun_java_wireless_toolkit-2_5_2-linux.bin<br />
./sun_java_wireless_toolkit-2_5_2-linux.bin<br />
</code></p>
<p>For some reason this package complains it can&#8217;t find Java interpreter.  If this happens, the Java 5 JDK is located <tt>/usr/lib/jvm/java-1.5.0-sun/bin</tt> on Ubuntu.</p>
<p>Once extracted, unless you plan on doing vanilla J2ME development, you can copy the preverify tool and then delete the WTK.</p>
<p><code>mkdir ~/bin<br />
cp ~/lib/WTK2.5.2/bin/preverify* ~/bin<br />
rm -r ~/lib/WTK2.5.2<br />
</code></p>
<p>Don&#8217;t forget to put the <tt>~/bin</tt> directory in the execution path.  To have this set automatically each time you login, put this line in your <tt>~/.bash_profile</tt> file (create it if necessary).</p>
<p><code>export PATH=~/bin:$PATH</code></p>
<h1>Compile &#8220;Hello, World!&#8221;</h1>
<p>I&#8217;ll be using <a href="http://ant.apache.org/">Apache Ant</a> for building because it&#8217;s the common denominator when it comes to building Java projects (like it or not).  Most IDE&#8217;s have some level of support for running ant scripts.</p>
<p>Install ant:</p>
<p><code>sudo apt-get install ant</code></p>
<p>Download <a href="http://sourceforge.net/project/showfiles.php?group_id=195339">bb ant tools</a> and put it where ant can find it:</p>
<p><code>unzip bb-ant-tools-0.7-bin.zip<br />
mkdir -p ~/.ant/lib<br />
cp bb-ant-tools.jar ~/.ant/lib<br />
</code></p>
<p>Download the <a href="/download/hello.tar.gz">hello world</a> project and run <tt>"ant"</tt> in the project directory:</p>
<p><code>wget http://www.slashdev.ca/download/hello.tar.gz<br />
tar -xzf hello.tar.gz<br />
cd hello<br />
ant<br />
</code></p>
<p>Output from the ant should look something like this:</p>
<pre class="console">
josh@ubuntu:~/hello$ ant
Buildfile: build.xml

build:
    [mkdir] Created dir: /home/josh/hello/build
     [rapc] Compiling 1 source files to ca_slashdev_hello.cod

BUILD SUCCESSFUL
Total time: 1 second
</pre>
<h1>Signing</h1>
<p>To sign your cod files, follow my guide on how to <a href="/2008/03/16/using-sigtool-in-linux">fix the signature tool</a>.  Then just run the <em>sign</em> target in the build script.</p>
<p><code>ant sign</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>
