Category ArchiveSoftware
Project54 & Software marktaipan on 05 Apr 2010
Reading Serial Data from Virtual COM Ports
While most desktop developers do not have to deal with Serial COM ports (and I doubt many people miss it), here at Project54 we use COM ports to communicate with a variety of devices (GPS Antennas, Radars, Video Systems, etc.). For anyone that is familiar with programming COM port communication in the Win32 platform, they will most inevitably use the same functions (e.g. CreateFile(), ReadFile()) as outlined here at MSDN.
Like other communication protocols, one has to consider whether to use synchronous or asynchronous communication. With COM ports, asynchronous transmission is defined by using an OVERLAPPED structure and combining it with events to watch out for. For synchronous communication, one would omit the use of the OVERLAPPED structure and will replace it with the use of the COMMTIMEOUT structure (which allow programmers to define the timeout parameters for the ReadFile() and the WriteFile() commands). Most of the time, using this COMMTIMEOUT structure will cause expected timeouts and stop the ReadFile() and the WriteFile() functions from blocking indefinitely. However, there is a case where this is NOT true.
When using Virtual COM Ports, performing synchronous communication will cause the ReadFile() and the WriteFile() to block, regardless of the timeouts you define in the COMMTIMEOUT structure. The workaround to this is to make sure you use the OVERLAPPED structure for asynchronous transmission and define a timeout in a WaitSingleObject(). Below is a piece of example code for asynchronous COM communication.
Also, check out this great resource for serial communication with Visual C++.
OVERLAPPED overlapStruct; // Overlap structure for asynch. serial comm.
memset(&overlapStruct,0,sizeof(overlapStruct)); // Zero out the overlap structure// Handle used to correlate an event with receiving data at the overlap structure
HANDLE hReadEvent = CreateEvent(NULL,TRUE,FALSE,L”COMRx”);// Correlate the overlap structure with the event
overlapStruct.hEvent = hReadEvent;// Number of bytes received by the overlap structure
DWORD bytesRet;// Buffer for data
char gpsBuffer[1024] = {’\0′};// Let’s try open the given COM Port
if ((hComPort =
CreateFile(L”\\\\.\\COM1″, GENERIC_READ | GENERIC_WRITE,
0, // exclusive access
NULL, // no security attrs
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL )) == (HANDLE) -1 )
{
// ERROR: Looks like we failed to open the COM Port.
return -1;
}// Try grab the data from the buffer
ReadFile(hComPort, gpsBuffer, sizeof(gpsBuffer)-1, (LPDWORD)&numRead, &overlapStruct);// Wait for data to come in through the OVERLAPPED Structure (COM Port)
if(!HasOverlappedIoCompleted(&overlapStruct))
{
// Time-out after 5 seconds if we do nothing has happened with the handle
WaitForSingleObject(hReadEvent,5000);
}// Let’s check to see if we have a result
int iResult = GetOverlappedResult(hComPort,&overlapStruct,&bytesRet,FALSE);
if( (iResult) && (bytesRet > 0) ){
//
// Got some data from the COM Port
//
}
Mark Taipan
Just for fun & Software zeljko.medenica on 11 Mar 2010
Project Natal for Xbox
This really looks like Wii on steroids! I have recently stumbled upon Microsoft’s Project Natal for Xbox. Their slogan is “You are the controller” which is really appropriate. The system uses full body motion, facial and speech recognition in order to improve the sensation while playing a video game. This means that no electro-mechanical controllers are required, but rather everything is done using different body parts. Plus, more than one person can participate in the game. If you are interested, take a look at this video. It really looks like it has a potential to revolutionize a new way of gaming.
Zeljko Medenica
Software & Tips and tools zeljko.medenica on 10 Feb 2010
Irregular selections in Excel
Have you ever had a need to filter some tables of data in Excel using masks? If so, this post may be useful to you. The principle is simple: place your data in one sheet (Data), create a mask on another sheet (Mask) consisting of cells filled with ones (where you want to keep the data) and zeros (where you want to remove the data), and finally, just multiply the cells of the previous two sheets in the third sheet (Filtered). A simple example is shown in the picture below.

However, the problem arises if your original data contains zeros, so in the destination sheet (Filtered) you won’t be able to decide which zeros are the “true” data and which are the result of masking. Since Excel doesn’t allow creating irregular selections, we are unable just to select all the zeros from the mask and paste it on top of our true data.
One way around this problem is as follows. Copy the whole mask into the destination data sheet right below the filtered data. While the whole mask is still selected, press Ctrl-F to invoke the “Find and Replace” window. In the search field write “0” and check “Match entire cell contents”. After pressing “Find all”, Excel will create a list of all cells (inside our selected mask) that have zero values at the bottom of the same “Find and replace” window. Now, leave this window opened and just copy the values of our filtered (or original) data on top of this mask (inside the “Filtered” sheet). After selecting all elements of the previously created list of cells inside the “Find and Replace” window, we will get the selection that we want to eliminate on top of our data.

This procedure was demonstrated on a very basic example. However, I found it very useful when the data tables become huge, which make manual selection of undesired cells extremely error prone. There is also a possibility to record a macro which would make this whole procedure automatic and bring it to a whole new level.
Zeljko Medenica
Science & Software erickjanampa on 16 Jul 2009
Program discovers Newtonian Laws
I found this article about people from Cornell University creating a powerful computer program that was able, due to some major calculations, to figure some scientific laws of physics such as the Newtonian Laws. It’s pretty cool to know that a program could do that and that in the future it might be able to help us discover new things about science.
Even though it was more like a program full of trial and error, with a supercomputer and a lot of memory, we could try a huge amount of formulas and get results faster than humans can.
http://www.wired.com/wiredscience/2009/04/newtonai/
Erick Janampa
Mobile phone & Project54 & Software & Technology eric ojala on 22 Jun 2009
DTK Barcode Reader SDK Report
One upcoming necessity here at Project54 is the need to be able to scan licenses using a mobile phone camera. I designed an experiment involving many different camera capture formats and post camera capture image processing techniques to see which of these produced the most successful results using the DTKBarcode Barcode Reader SDK.
This scenario involved the following camera parameters:
- HTC Touch Pro
- 3MeagPixel Picture
- Default Saturation
- Default Sharpness
- Default Contrast
- Distance between camera and barcode: About 7 inches
Results:
These two barcodes are from the same picture, the bottom one (Figure 2) being the original. The only property physically different between them is the top right and bottom left corners of the top barcode were skewed two pixels inward using Adobe Photoshop CS3. The result of this skew is shown below (Figure 1). This minute change enabled the barcode to be read by the DTK Barcode Reader SDK.

Figure 1 : SUCCESSFUL Scan by the DTK Barcode Reader (Photoshop Skewing)

Figure 2: FAILED Scan by the DTK Barcode Reader (Original HTC Camera Photo)
Conclusion:
I took well over 300 pictures with varying settings. I took my best three cases (Grayscale, Sharpness +5, Saturation +5), each with only 50% success, and applied additional image processing, post capture, with Photoshop. The most successful Camera settings and Photoshop techniques were additional Saturation, Sharpening and Color Level manipulation, with none being much more successful than the others. The best I could raise the scan success rate to was 75%, for one test case, using a combination of all three techniques. Keep in mind that I was sitting, using two hands, and stabilizing the camera with my elbows on the table. The realistic case would be more along the lines of someone standing, holding the phone with one hand and the license with another, with no additional stability support. It seems with this margin of error, the DTK Barcode Software will not be able to meet our needs.
Perhaps someone else has an answer or suggestion to solve this problem?
Eric Ojala
Conferences & DSP & People & Project54 & SDR & Software & Technology Ivan Elhart on 14 May 2009
2009 IEEE International Conference on Technologies for Homeland Security - HST 2009
On Monday, May 11, I was honored to present my work at a very prestigious IEEE conference on Homeland Security technologies, held in Waltham, MA. During the technical session on the interoperability and field deployable communications, I gave a presentation on the design and development of a software defined Project 25 data base station. Here is a picture taken during my presentation:

First, I took a couple minutes to introduce data communication and talk about potential benefits of having data messages in public safety communication system. I continued my presentation by talking about the problem of very expensive Project 25 equipment that hinders the implementation of data communication in small police departments. Our approach towards a software defined data base station seems a promising and cost effective way for local departments to bring data messages into their cruisers. A very precise and rigorous testing procedure performed in our laboratory showed the compliance of the base station with commercially available P25 radio equipment. Also, the test procedure produced promising and encouraging results prior the real world deployment in a local NH police department. Finally, I concluded my presentation with a demo video which demonstrates an application of querying a remote server using the data base station and Project54’s speech user interface. Here are the slides:
After the presentation I answered a few great questions and received a lot of positive comments about our work on the radio interoperability at UNH and Project54.
Special thanks to Dan Farfan from KinetX Inc., who was so kind to take pictures of me presenting.
Ivan Elhart
Software & Technology & Tips and tools Alexander Shyrokov on 19 Mar 2009
Collaboration on documents
I was advised to use FolderShare application to share documents with my collaborators. But, in fact, we already have subversion for our code development. This automatically raised a question of why would we use FolderShare if we already have subversion installed on our server and in operation. It is not reasonable to compare subversion with FolderShare, because the purpose of these applications is very different, but it is possible to compare them for the task of collaboration on documents. So here we go:
Setup: there is an article me and my co-author want to write. Let’s call it OurArticle (it does not matter in what format the article is).
FolderShare:
1) I edit OurAricle and copy it into our shared folder (I can not edit it inside the shared folder, because it’s not clear what will happen if both of us edit it at the same time).
2) I email the co-author that changes are done
4) The co-author copies OurArticle somewhere else and edits it.
5) The co-author overwrites OurArticle in the shared folder.
6) The co-author emails me that I can work on the document.
Copying and overwriting is a clearly error-prone process. No version control, no automatic notifications, no error checking (FolderShare does not care if I overwrite the co-author’s change with mine, without even knowing I did it; FolderShare does not prevent me from editing document in the shared folder, saving it and then overwriting it with the old copy of the file that I was supposed to edit and then copy).
Subversion:
1) I commit my edits (this automatically sends notification to my co-author).
2) The co-author updates his copy (subversion will check if merging is required automatically).
3) The co-author commits his modifications (I get automatic email).
This is clearly a better solution. The most important is that subversion prevents us from loosing our modifications, by automatically checking for these modifications. We also get automatic version control for the article, in case we want to revive the paragraph we deleted a few editions ago.
FolderShare is suitable for sharing static data between computers, such as pictures, videos, etc. It’s not designed to handle collaboration. Subversion does require a server running with properly installed software, which is a hassle (luckily we already have it set up, so we get only benefits).
To top it off, subversion does not require a sync application constantly running in the background (better computer performance); subversion gives a third location for the backup; with subversion we have a web interface which allows us to get to the files without installing anything.
If we have to share some videos that do not require modifications, then FolderShare is a go. I also found out that there is a different alternative DropBox, which allows version control of the files, as well as the web access. It looks like if we would not have subversion already installed on our server, DropBox might have been a better solution for collaboration on the documents.
Any comments?
Alexander Shyrokov
R&D & Science & Software & Technology Alexander Shyrokov on 16 Jan 2009
Experiment Wizard
This is a follow up to my previous post about automation solution for our experiments. Taking the automation a step further I have designed Experiment Wizard.
Experiment Wizard is a cross platform open source automation tool for scientific experiments. It defines the XML schema for experiment administration, and provides GUI application to execute created experiments. It can be a replacement of a checklist or a complete automation tool. It can be used for human-human or human-computer experiments or any other type of an experiment that uses computers, which can be connected into a network.
Go to Experiment Wizard home page to download the Executable for windows or sources that can be compiled on another operating system. It comes with a tutorial and documentation for the schema file. Any feedback is welcome.
Alexander Shyrokov.
Just for fun & Software & Technology marktaipan on 14 Jan 2009
ImagineCup SDI
Hey everyone!
My name is Mark Taipan and in addition to working for the fine folks here at Project54, I also am the Microsoft Student Partner here at UNH. One of the topics that I’ve been discussing with students last semester is the ImagineCup competition. So what is the ImagineCup? And what is SDI?
The Imagine Cup is a worldwide competition held by Microsoft that allows students over the age of 16 to create projects that fulfill one of the UN Millennium Goals. There are a total of 9 categories that students can compete in and the Software Design Invitational (SDI) is one of them. The SDI competition allows teams, of up to 4 students, to create software using Microsoft technologies in attempt to make the world a better one to live in. Check out this SDI group who competed last year at the US final.
The competition is broken up into several rounds; most notably, the international final round is in Egypt! However, the SDI first round deadline is fast approaching (Thursday, January 22nd, 2009). Don’t be discouraged if you haven’t started a team/project yet as the First Round involves NO programming at all. If you have a great idea that fulfills the criteria of the competition, take a few hours and submit your idea for the First Round. Think of this round as the proposal of your product; just your idea and a plan is needed here.
Why bother competing?
• If you’re an UNH ECE major, jump start your senior project!
• It’s a great way to bridge the knowledge attained from the classroom with a fun, interesting project designed by you
• Resume builder
• Raffling of prizes for those that UNH students who compete in the SDI competition along wiht the ImagineCup Prize (Overall 1st Place Team wins $25,000)
• Most importantly, use technology for a good cause!
Want more information?
US ImagineCup Website
International Website
Upcoming Dates:
SDI Public Training: Thursday, January 14th, 2009
(Specific information here)
Round1 Deadline: Thursday, January 22nd, 2009
(Register first here)
So if you’re interested in competing in the competition, contact me at mtaipan@gmail.com. I am more than happy to assist you in the logistics of any of the categories in the ImagineCup and help your team brainstorm ideas for the SDI competition. Also, stay tuned in for more info about various Microsoft-related news in the upcoming semester!
Project54 & R&D & Software & Technology & Web Alexander Shyrokov on 15 Dec 2008
Computerized questionnaires
During our experiments we use questionnaires to collect some data. So far we have used paper questionnaires. The major advantages of paper questionnaires are: ease of administration (subjects know what to do with them); and ease of creation (using a word processor). On the other hand, there are two major flaws: unintentional incompleteness (subjects miss some questions); and data entry errors (transfer from paper to digital form is error prone). We are looking into an alternative method of questionnaire administration. The most likely solution is the delivery of computerized questionnaires through a survey application, such as LimeSurvey, an open source php based survey application. LimeSurvey allows an easy creation of questionnaires, while providing full control over the survey presentation. The questionnaires and data can be exported/imported using csv format. Questionnaires can also be printed and with the help of queXML and queXF the conversion of the data from paper into digital format can be automatic.
Alexander Shyrokov