Tuesday, October 23, 2012

Android Tablet FTP via Wifi

The motivation of this post is to raise the awareness of a possible problem of Android FTP client programs.

At this point, I am not sure what's the real problem. So I will simply describe what I did and what happened.

I bought a no-brand Android Tablet. It runs Android 4.0.4 with Kernel of 3.0.8. Every thing works great until I begin to work with the FTP. I download every free FTP program that is compatible with my tablet and none of them worked flawlessly. There are times the error is caused by Java.net.SocketTimeoutExceptions. But a lot of times, it simply stopped. They happened pretty much randomly. Almost all programs/apps connect to my server at some point. But none of them can reliably maintain the connection for long enough time. I am not ruling out the wifi connection of the tablet since at times, it does not have the idea connection.

With the same wifi setup, I run the FileZilla on a Windows 7 laptop. Everything works great. No problem what so ever.

Of all of the Android FTP client apps, the most reliable one. At one point, I was able to make couple of download and upload. But, eventually, it hanged. The FTP clients I have tested are: AndFTP, ZealFTP, DroidFtp, AbyssFTP and FtpCafe.

Monday, May 14, 2012

GUI for Constructing Command Line - Concepture Design

The purpose for this article is to propose a conceptual design for a generalized GUI tool that can help user constructing a valid command for command line interface. The design is to be general and capable to handle as many command line specification as possible. In the process we also like to be able to enforce syntax rules as much as possible.

As I work through the idea and prototype, I will continue to update this article.

The design begins with the data structure.

After re-examining the problem, I am settling to a data structure that would not be able to represent faithful implementation of all possible command line construct. What this mean is that we may not be able to parse a command line correctly based on our data structure for certain command. This, however, does not preclude us from produce legitimate command line. A category of command line construct that could not be faithfully represented by this data structure design is those commands that allows the required options to be presented in random orders. Our data structure will put those options in an order and, therefore, won't be able be used to parse command line that presents those option in different order, which were allowed by the real command line interpreter.

Child Node Type:
(o) - Child nodes are in (o)rder and are defaulted to be required.
(-) - Child nodes are all optional. Actions are needed to include them in the command line.
(1) - Exactly 1 child node is need to presented in the command line.
(0) - No child node. Optional text value and default flag or required keyword
(r) - The child node can be repeated as many times as possible.

Common attributes for nodes:
  Slctd - selected
  Dscrptn -
  Syntx -
  Vl - value
  VlRE - for checking Vl
  Optns - No value, default ...

Possible construct:
copy -Src SrcFl -Dest DestFl -Ascii -LF
  copy (o)
    -Src FlNm (0)
    -Dest FlNm (0)
    ways of copy (1)
      -Ascii (1)
        -LF (0)
      -Binary (0)

*The above structure may not faithfully represent the copy command if the copy command allowed this construct:
  copy -Dest DestFl -Src SrcFl -Ascii -LF

<?xml version='1.0' encoding='UTF-8'?>
<!-- This document was created with Syntext Serna Free. -->
<Nd SyntxKy="Copy" >
  <Dscrptn>copy a file</Dscrptn>
  <Chld Typ="o">
    <Nd SyntxKy="-Src" >
      <Dscrptn>file to be copied</Dscrptn>
      <SyntxLtrl>-Src </SyntxLtrl>
    <Nd SyntxKy="-Dest" >
      <Dscrptn>file to be copy to</Dscrptn>
      <SyntxLtrl>-Dest </SyntxLtrl>
    <Nd SyntxKy="ways of copy" >
      <Dscrptn>file type</Dscrptn>
      <Chld Typ="1">
        <Nd SyntxKy="Ascii" >
          <SyntxLtrl>-Ascii </SyntxLtrl>
          <Chld Typ="1">
            <Nd SyntxKy="LF" >
              <Dscrptn>Convert line break to LF</Dscrptn>
              <SyntxLtrl>-LF </SyntxLtrl>
            <Nd SyntxKy="CRLF" >
              <Dscrptn>Convert line break to CRLF</Dscrptn>
              <SyntxLtrl>-CRLF </SyntxLtrl>
        <Nd SyntxKy="Binary" >
          <Dscrptn>byte by byte/literal copy</Dscrptn>

GUI design:
(-) - checkbox
(1) - radio button
(o) - linked control group:
    An ordered node syntax:
      (o) (-) (t) Optn1
              (t) Optn2
              (t) Optn3
              (t) Optn4
          (1) (t) OptnA
              (t) OptnB
    Can be expressed in a graph like:
      |         +--+        |
      |   Optn1 |  |o OptnA |
      | x Optn2 |  |o OptnB |
      |   Optn3 |  +--------+
      |   Optn4 |

A possible description in XML can be:

Thursday, April 12, 2012

MS ACCESS binary field and make table query

The MS ACCESS binary field is basically a BLOB field if you familiar with DB2 or DEC terminology. It is simply a field that can hold a chunk of data of some kind of format. It can hold video, audio, text ... etc. Or you can think of it as un-typed field.

When using MS ACCESS (till ver. 2007) through its normal user interface to create a table, ACCESS do not offer users the option of creating fields of type 'binary' even though it does offer types like OLE object that allows users to store picture, video, ... etc. Binary fields, however, can be create via making table queries which I discovered by accident.

For more information about the BLOB and MS ACCESS binary field please see:

Wikipedia on BLOB
MS ACCESS binary equivalence in other DB (MS article).
Binaries in MS SQL server (MS article)
How binary may be used in VB/ACCESS (generation-nt.com)

You can create a binary field by using [Yr(yyyy)=] in a make table query, MS ACCESS will create a binary field for it. It seems that the binary type is the default for make table query unless the ACCESS can derived the type from other information -for example, the type of the data source. In general, the SELECT statement in the make table query will provide these information. So the SELECT Fld1, Fld2 ... FROM SrcTbl INTO TblCreated ... will create fields based on the type of FldN in the SrcTbl. It is when you use the syntax: [Yr(yyyy)=]  in a create table query that the ACCESS will run into troubles on determine the correct field type. You can overcome this by providing additional information in the form of the type of a function. For example, with CLng([Yr(yyyy)=]), ACCESS will make the field a type of long-integer.

Once the field is created, it seems to me, the field will take any kind of value you inserted into it even though the data may not show in the way you expected. For example, if you insert a integer to the binary field, it may look like you inserted an ASCII code and shown as a character.

I do, however, have trouble to understand the failure of some of my queries that create a binary field. One of my queries is a complex query that invoke several other queries as its source. The query contains prompting syntax (i.e. []) for various purposes. Some of them are used to filter the data source and one of them is used to create the binary field. That query successfully create the table with binary field when all records are filtered out. However, when valid records were to inserted into the created table via that same query, error was reported that there are type conversion errors and the binary field was inserted with NULL. The value to be inserted was the value assigned to the prompting syntax in the form of integer. This is what bring me to the investigation of the ACCESS binary field originally. Unfortunately, as mentioned earlier, binary fields seem to be able to take in any type of data except in my particular cases (There are actually two very similar queries that failed).

Life goes on, so I will leave this mystery for someone else to solve.

Tuesday, February 28, 2012

Problem: PSPP on Windows Vista

The purpose of this blog is to record the problem I run into when running PSPP on Windows Vista. For a quickie, PSPP is a GNU SPSS. It was designed for POSIX /Unix  machine and was ported to Windows by several authors. As of today (2012/02/23), there were reported problems for Windows Vista/7.

My use of the PSPP is to handle the files download from the 'DOWNLOAD SURVEY DATA FILES' option of the IPEDS Data Center. The download comes with one .csv data file and one .sps program file. The downloaded .sps file usually need be adjusted a bit for syntax errors. Other than that, those file are in great shape.

I have been using the PSPP v0.7.2 (2009-05-18) from michelboaventura.com on Windows XP machine to do this for quite a while without a problem. Recently, I installed the same version on my Windows Vista machine and I notice that the .csv data file would not be imported into the PSPP worksheet by the .sps 'get data' command. This is eventually solved by adding the 'set workspace=1000000000' command at the beginning of the the .sps file as suggested by awardspace.com. After that everything works fine for the version v0.7.2 from michelboaventura.com.

While I was having trouble with v0.7.2 on Vista, I tried the following newer versions:
v0.7.8 (2011-11-11) from michelboaventura.com and
v0.7.9 (2012-02-16) from awardspace.com.

For v0.7.8, I was able to get the .csv file into the PSPP worksheet window if I add the 'set workspace=1000000000' statement. However, when I try to process the 'variable label' command that is next in the .sps program, the PSPP windows will gray out and doesn't seems to make progresses. When I click the PSPP spreadsheet window, Windows Vista reported that the program has crashed. One extra thing I did with this v0.7.8 is to use the pspp.exe to process the .sps file and it run through the process with no problem - I don't even need the 'set workspace=1000000000' statement.

For the v0.7.9, the installation is successful. But when ever I start the psppire.exe GUI, Windows Vista reported the program has crashed. I did not pursue more on this one.

Monday, February 6, 2012

RODBC sqlSave() autonumber auto-increase problem

This is a quick note on R.

The RODBC package for R-project is a popular add-on to access ODBC database. The sqlSave() function is a common method used to save a data.frame to an ODBC table. For an ODBC table with autonumber or auto-increase fields, this function reports errors. Turning on the verbose option of that function, it is observed that sqlSave() constructed a SQL statement that ALWAYS intended to insert values to all table fields. With this SQL statement, user are forced to assign a value for the auto-increase field, which, by its own definition, should not be assigned a value from external source.

For some odd database implementation, you might be able to assign a null value to the auto-increase field and got it to work. But, as far as I know, the MS ACCESS would not take that.

I was trying to find the source code for the RODBC package but was unsuccessful. I do found that if I wrote a function so that it write the data.frame to database using the sqlQuery() function, this can be overcome. However, this may take longer to process the data. The idea solution is to modify the sqlSave() function so that it is more flexible.

I also run into the problem with sqlSave() when dealing with two MS ACCESS memo fields. Again, this can be solved with the sqlQuery() function.

MySql MyOdbc MS ACCESS server has gone away error

While using MS ACCESS to connect to MySQL database through MyOdbc, I constantly got the following error: 'server has gone away error #2006'.

After searching the MySql site with no success, I finally find the solution at: SiteGround Forum posted by hwj.

Basically, when create DSN in Windows using ODBC configuration tool, you need to enable the option auto-reconnect immediately before you click OK to exit. According to hwj, if you did not do it while you creating the DSN, you will have to start over.

This works for me!

Hopefully, with this link, it will promote that article in Google search.

Saturday, January 28, 2012

Internet Based Weather Warnning System

It's just an idea I proposed to National Weather Service a while back.

The general idea is for the National Weather Service to provide Lat/Lon based Weather Warning information to user's computer and allow user's computer to sound the speaker.

There could be several ways to implement this. For privacy concerned user, the user can run a daemon/service program on their computer and poll the weather server periodically. The other possibility is to have user registered with the server and have the server send out appropriate warning message only to computer that facing severe weather condition.

I suppose this can be extend to any kind of warning message. The real question is how we implement it. The RSS or tweeter feeds are possible, but that will require intelligent client software to decode the message and issues alarm accordingly.