Serial Comms Example Source Code

hippy

Technical Support
Staff member
Example source code for a simple Terminal Emulator; whatever is typed gets sent out the serial port, whatever gets received is shown in the display window. It should demonstrate the basics of configuring and opening ports, handling received data and sending it

http://homepage.ntlworld.com/the.happy.hippy/picaxe/terminal.zip (70KB)

I've tried to keep the example code as consistent as possible for all versions to make it easier to relate a language that may be familiar to one which is not.

Example code for -

* FirstBasic / PowerBasic for MS-DOS
* RealBasic 2007r4
* VB3 Professional
* VB6 Professional (SP6)
* VB 2005 Express Edition ( aka VB8 )
* VB 2008 Express Edition Beta 2 ( aka VB9 )

No pre-built .EXE for RealBasic ( 3MB+ ! ) nor for the VB 2005/2008 builds to keep the .ZIP file size down. Run-time libraries, .DLL's, .OCX's may be needed to run the .EXE files.

The serial port defaults to COM1 but can be changed by running the .EXE files from the command line with a port number following ( eg, C:\Tmp\Vb6\Vb6.exe 2 ), by altering the source code or setting a Command Line Arguments within the debugging environment of the IDE.
 

jonphenry

New Member
Heres the same basic type of app in C# Hippy. I found it at the codeproject and was easily able to use it with the picaxe. It works perfectly.

http://www.lancer3.com/dwnlds.htm

My programming skills are very basic. Im sending three variables from my 40x1 into the pc. What Im trying to figure out is once I have this data in the softwares input buffer, how do I get each piece of data separated to use in different things(ie labels,gauges,etc.)?
 

kranenborg

Senior Member
Hello,

I was able to build an executable directly from jon henry's code, and the executable seems to work (that is, I haven't a picaxe connected, but the window that is popping up seems completely OK and allows me to type in a string and send it in the blue sky ...)

However, hippy's vb2005 exampe didn't build, I got an error message saying:
"Error 1 Unable to find manifest signing certificate in the certificate store. project: Vb2005 "

As I have some BASIC experience ( -PICAXE -), hippy's source code seems more accessible to me, but I do not understand the error message (I have no Visual studio programming experience whatsoever, so maybe my total lack of knowledge is the root cause) . Have I done something wrong trying to build an executable? (I need to remark that I do use the professional edition of Visual Studio 2005, not the free express edition). An answer saying that I should begin with VS itself first is perfectly acceptable to me as well...

Regards,

Jurjen
 

hippy

Technical Support
Staff member
@ Jurgen : Not sure what's wrong there as I'm not familiar with VB 2005 but thanks for the heads-up. I'm starting to hate the VB 2005 IDE with a vengeance. Trying to copy one project as another is a nightmare ( No "Save Project As" as best I can see ), and I guess it's no longer the case of just shipping two or three files as with VB6.

I'll investigate and see if I can find what's missing or what needs to be changed to make it compile. Grrr. Thanks Bill G.
 

hippy

Technical Support
Staff member
It compiles when unzipped into an entirely new location so it has to be something on my PC. I think it's because I imported it via the VB6 upgrade wizard.

Have a look in Project->Vb2005 Properties->Signing and untick the "Sign the ClickOnce manifests".

You may also have to go to Security and untick the "Enable ClickOnce Security Settings".

If that doesn't fix it I think we'll have to wait for someone with VB 2005 experience to come along.

I'm also not sure what happened in the .ZIP file. XP shows lots of empty directories, WinZip under Win98SE just shows a handful of files. I'll get that sorted as well.
 

kranenborg

Senior Member
Hippy,

Having implemented both of your suggestions, i.e:

* Project->Vb2005 Properties->Signing and untick the "Sign the ClickOnce manifests".
* Security and untick the "Enable ClickOnce Security Settings".

improves the situation: the build succeeds and an vb2005 application is created (only the first suggestion seemed to be necessary

Still a small problem remains: a terminal emulator program pops up, but seems deaf to any keyboard input ...

/Jurjen
 

hippy

Technical Support
Staff member
Good to see it's getting there

Still a small problem remains: a terminal emulator program pops up, but seems deaf to any keyboard input ...
There's no local echo so nothing shows if nothing comes back or gets sent from the PICAXE. The easiest solution is to loop back TX/RX on the PICAXE download cable while disconnected from the PICAXE -

For 3-Pin Molex, link orange to red, ignore brown (0V). A bit of wire works well for that.

For 3.5mm Jack, link ring to sleeve. Protect tip (0V) with masking tape and use one end of a croc-clip is my method.

It also sends on COM1 by default. If your cable's on a different port the easiest option within VB 2005 ( and hopefully VS 2005 ) is Project->Vb2005 Properties->Debug then "2" or whatever for the COM port in Command Line Arguments. Run within the IDE it should work.

For running the .EXE; Task Bar Start->RUN, "C:\whereitis\Vb2005\Bin\Vb2005.exe 2" etc.

There's a line in the serial receive routine "CheckForIllegalCrossThreadCalls = True" - that can be deleted / should have been. It has no adverse effect if left in though.
 
Top