Sunday, May 18, 2008

Trick to track the argument in console

On last week, I was working so hard to put in three features for the search program.

FEATURE LIST:

- Search path. This feature allows dynamically to search the desired path
- List. This is to show out the search result.
- Output. Export search result to text file.

The first two already done. Third feature still in progress.

During this experience project, I found a very interesting issue. How to track the input passing in through the command line? Lets take a look:

void main(int argc, char *argv[], char *envp[])

Initially I was using argc to track how many command was passing in. This is not really a good method of doing this because when passing in more and more options, it duplicate the same task. Refer to the code below:

switch(argc)
{
case 1: // no option was pass in
break;

case 2: // 1st option was pass in
break;

case 3: // 1st and 2nd option was pass in
break;

...
...

case n: // until n number of option was pass in
break;
}

Anyhow I have overcome this issue by tracking down the number of command passing in by using the argv pointer array. If argv[1] is empty, definitely I know that option number 1 is not there. Otherwise there must be an option passing in. For doing that, I just need a while loop to track every element in argv. But how do I know how many option was passing in? By using NULL checker? Actually I was using argc to get the total element in argv. I get this inspiration from MSDN.

Sunday, May 4, 2008

My first day in C++ .Net.

The first application that adopts this technology is my search file console program. The objective of this program is to retrieve all the files by searching through the particular location (including the remote media and network media).

I am having trouble at the first run. I mean every time I start something new, I’ll create a simple “Hello World” program to make sure everything are in place. “Something new” means this my first time in .Net development. The compiler that I am using is Express Edition 2005. At first I create an empty project from the general category. When I build the program by choosing “Start without Debugging” option, everything went fine. But it will prompt a message if I build using “Start Debugging” option.

The contents of the message are as below:

Debugging information for 'XXX.exe' cannot be found or does not match. Binary was not build with debug information.

This is not an error I guess, it just unable to retrieve the debug information. I do not know how to solve this problem, if you read this post and have any suggestion on this, do let me know. Thus I have to recreate the project by choosing “Win32 Console Application” under the Win32 category.

Now, the primary keys to deal with Files are DirectoryInfo, FileSystemInfo, and FileAttributes. The sample below will show all the files (not directory) in C drive.

DirectoryInfo ^di = gcnew DirectoryInfo("C:\\");

for each(FileSystemInfo ^fsi in di->GetFileSystemInfos())
{

if(fsi->Attributes != FileAttributes::Directory)
{
Console::WriteLine(fsi->Name);
}
}

Sunday, September 23, 2007

My modem is working now

The modem is alive. It is working now. I am posting this from my Linux box. I feel so happy now as I have spent quite a number of days to configure my modem. To search for the latest modem driver is not a hard job but configure it to make work is a hard job. Right until now, the modem still haven't correctly configure. Every time I turn on my Linux I still need to configure it in order to get online. By the time I configure the modem, it fails for the first time when I try to connect to the Internet.

An error message prompt timeout expired while waiting for the PPP interface to come up. This is so annoying for me to click on the OK button every time I connect to the Internet. This is annoying too every time I need to configure my modem after Linux was bootup.

Things going to solve soon. I need some configuration setting to make my modem “permanently” stay in my Linux.

Sunday, September 16, 2007

Tools to detect my modem

I have downloaded a tool called Scanmodem from linmodem support page while I get into this HOWTO slmodem for Gentoo. I know this site is definitely for Gentoo Linux, but I was running out of hope to install my modem. There are so limited resources out there. I must give try on whatever I found.

This tool can help you to detect your modem device, the files needed to compile your modem and many more. It was a very good tool. To use it, follow this simple steps:

gunzip Scanmodem.gz
chmod U+X Scanmodem
./scanModem

- gentoo-wiki.com/HOWTO_slmodem

This will create a ModemData.txt under a Modem directory (there are many more files generated). So I open up the file and I see a lot of info which I couldn’t understand. The very interesting part to me is this:

PCI ID: 2000:2800
Subsystem ID: 122d:2800

…
…

Candidate modem in PCI bus: 00:0c.0
Class 0703: 200:2800
Primary PCI_id: 2000:2800
Type needed: slamr


After reading this, so called spec, I become blur and struggle. It seems helpless on Internet after a few weeks of searching and googling. The only hope is to go back read carefully the README from the package. This is the only hope I think.

One thing for sure is my modem chipset is SL2800.

Saturday, September 15, 2007

First try on installing a modem on Mandriva 2007

Few months ago, when starting to setup my Linux box on my machine, the primary installation before development tools is the modem driver and display driver. The first driver I was trying to install is the modem driver. This driver is come together with the hardware. Unlike the display driver, this free me some hassle work in searching for the driver.

I am surprising that I am able to see the driver source code after I have extract the zip file. (I am new to the Linux world.) There is no exe file. I go through the instruction from the README file and following every step to in the setup process. It gives me an error. This is so interesting that the console showing which line is having trouble in which file. Just like a debugger. I follow what have been told by the compiler to see what is inside the code.

Open it. I have no idea on how to fix the code although I am a C++ developer. (Frankly my core skills are UI only.) This is so funny that I can read the C++ code but I have no idea on how this code is work. I put this aside for a few weeks until I manage to find a latest driver. I get the package from here.

It compiled and installed but I have no way to configure it. Did some Google search and I got this thread. This thread did mention about on how to setting up and configuring the modem. It works exactly. Unfortunately the modem is not able to query. Is it my false?

Wednesday, September 12, 2007

Changing Direction of My Project

I have a bad news. Due to the limited time I have, the project was drop as my initial plan. But something was change; I was planning to make a UI-less utility to make it simpler to develop. I don't need to care the about UI design issues, the feel and look. This project will be changing its development tools from MFC to STL. I was planning to make it executable in both window and Linux OS since I am switch my development environment to Linux.

Currently I was busy in setting up my Linux box on my machine. I have facing some troubleshooting issues during setup. (I am newbie in Linux.) Not the installation of Linux but the driver itself. It is pretty hard to find a driver in Linux. But I enjoy the process.

Monday, September 10, 2007

WHAT is Winmodem

WHAT is Winmodem

These few days working on Linux modem and been struggling in installing the driver. Winmodem and Linmodem are a new term which I see frequently during my searching process. I was curious about these and did a search from the Internet. This is what I got.

"A Winmodem is a software modem designed to work with the Microsoft Windows
operating system. A traditional modem uses hardware to perform its tasks, but
Winmodems perform their key tasks with software. This makes them smaller and
cheaper to produce, but it also means they cannot be easily used on other
operating systems because the driver support requires far more effort to
produce." - en.wikipedia.org/wiki/Winmodem

Another resource which talks more on this is available from this link.