Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
smileymicros
PostPosted: Apr 27, 2007 - 08:00 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

As promised a long time ago, I am posting a Developer Terminal and source code in C# and Visual Basic (both 2005 Express versions) and two draft chapters from a forthcoming as yet untitled book:
'Developer Terminal Manual.pdf'
'Modem Line Experiments.pdf'

All materials in this directory are draft and beta releases.I would very much appreciate any feedback, especially on typos and program bugs.

Please send all comments and concerns to joe[!]smileyMicros.com with the [!] replaced by @
No PMs on this please.


The free C# and Visual Basic 2005 Express editions are available at: (http://msdn.microsoft.com/vstudio/express) and provide an easy (relatively) way to create a PC side GUI (Graphical User Interface) for serial communication with a microcontroller.

I think that this would be a good way for someone interested in microcontrollers to learn to create PC GUIs and I'm willing to provide help (either on this thread or via emails) to anyone who wants to read the chapters and work through the materials to build the C# programs. In return all I ask is some feedback, especially looking for typos, stupidos, and what-tha-fuuu-os.

It seems that the downloads are two much for one post, so I'll put the source code in the following post.


Smiley

PS
The download may be named index.php, change that to Beta2Zipped.zip on your computer.

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
smileymicros
PostPosted: Apr 27, 2007 - 08:02 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

Source code.

4/28/07 replaced with Beta r02 to fix byte reception bug.

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com


Last edited by smileymicros on Apr 28, 2007 - 11:46 PM; edited 1 time in total
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Bingo600
PostPosted: Apr 27, 2007 - 09:07 PM
Raving lunatic


Joined: Apr 25, 2004
Posts: 3809
Location: Denmark

Smiley you might want to skip the # at the end of the C# source
If trying to download via the Projects link
You will try to get the file via this url (not found)
http://www.avrfreaks.net/modules/Freaks ... m%20C#.zip

You need to specify (%23 = # in hex)
http://www.avrfreaks.net/modules/Freaks ... 20C%23.zip

The above in threwad link works ok

/Bingo
 
 View user's profile Send private message  
Reply with quote Back to top
zbaird
PostPosted: Apr 27, 2007 - 09:26 PM
Raving lunatic


Joined: Aug 13, 2006
Posts: 6707
Location: Bellingham, WA - USA

I couldn't get the .exe files (how did you get multiple copies in those zip archives?) to run on XP, either the C# or VB ones. Probably something duh-mb I'm doing wrong? I know nothing of either VB 2005 or C# and have no other support installed.

_________________
Chuck Baird
"It's better to catch the trapeze than test the safety net" -- RPi book
http://www.cbaird.org
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
donblake
PostPosted: Apr 27, 2007 - 09:56 PM
Posting Freak


Joined: Jan 03, 2004
Posts: 1637
Location: Apalachin, NY, USA

zbaird wrote:
I couldn't get the .exe files (how did you get multiple copies in those zip archives?) to run on XP, either the C# or VB ones. Probably something duh-mb I'm doing wrong? I know nothing of either VB 2005 or C# and have no other support installed.
Either could I but after I rebuilt the VB .exe file, it ran okay.

BTW: Smiley was able to include multiple .exe files because they're in different paths. Path information is included in the .zip file. When you unzip the file, make sure you select Use folder names.

Don
 
 View user's profile Send private message  
Reply with quote Back to top
Jonil
PostPosted: Apr 27, 2007 - 10:01 PM
Wannabe


Joined: Feb 08, 2006
Posts: 62
Location: Sweden

Thank you for a great software, I've been using the old C# version for a while and it's working fine.
A question, is there a way to invert the data received and get the LSB first, for example if received 0x5B print out 0x25 (called inverse convention)?
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
smileymicros
PostPosted: Apr 27, 2007 - 10:44 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

Bingo600 wrote:
Smiley you might want to skip the # at the end of the C# source
If trying to download via the Projects link
You will try to get the file via this url (not found)
http://www.avrfreaks.net/modules/Freaks ... m%20C#.zip

You need to specify (%23 = # in hex)
http://www.avrfreaks.net/modules/Freaks ... 20C%23.zip

The above in threwad link works ok

/Bingo


Thanks for the catch. I just renamed the C# to Csharp so that should take care of it.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
smileymicros
PostPosted: Apr 27, 2007 - 10:46 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

zbaird wrote:
I couldn't get the .exe files (how did you get multiple copies in those zip archives?) to run on XP, either the C# or VB ones. Probably something duh-mb I'm doing wrong? I know nothing of either VB 2005 or C# and have no other support installed.


Ah... Okay, I did not intentionally include the .exe, but it is a good idea, so this weekend I'll generate a 'publish' file for the terminal that a Developer who only wants the executable can user without having to compile the code. Sorry I didn't think of that earlier, but I see this as a code learning exercise and now I realize that the Developer Terminal itself might be a useful tool as-is for folks willing to use .NET.

Thanks,
Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
smileymicros
PostPosted: Apr 27, 2007 - 10:53 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

Jonil wrote:
Thank you for a great software, I've been using the old C# version for a while and it's working fine.
A question, is there a way to invert the data received and get the LSB first, for example if received 0x5B print out 0x25 (called inverse convention)?


Thanks to the miracle of open source, the good news is "YES! You too can send reversed or inverted or any other kind of manipulated byte you can dream up... " The bad news is that you have to do it yourself. I will make myself a note to look at C# this weekend and see if there is a simple equivalent to a rotate or shift. This will probably be a bear in VB, but we'll see. If you figure this out before I get a chance, please post your solution.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
zbaird
PostPosted: Apr 27, 2007 - 11:00 PM
Raving lunatic


Joined: Aug 13, 2006
Posts: 6707
Location: Bellingham, WA - USA

I did get it working, after downloading the VB 2005 and service pack (takes its sweet time installing!), and then stumbling through the totally alien environment as compared to VB6. Anyway, it's a very nice looking interface and I'll be trying it out over the next couple of days. I've printed your manual and will read it later today, and glanced through the modem pdf file. You've got "let's" without the apostrophe in the first sentence, and that photo at the end - it would be nice to erase the shadows of the wires. More later.

This is just what I need to get off my butt and learn a little C# and VB 2005, so thanks for the inspiration. Plus for giving us a very useful program.

And Don, I appreciate the reminder about the folder names. Super Duh! to me; that's just the kind of thing I get hung up on for extended periods of time.

_________________
Chuck Baird
"It's better to catch the trapeze than test the safety net" -- RPi book
http://www.cbaird.org
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Jonil
PostPosted: Apr 28, 2007 - 12:23 PM
Wannabe


Joined: Feb 08, 2006
Posts: 62
Location: Sweden

Smiley, thanks for answer, I will try myself this weekend.

However, I found an error while receiving data. I cannot receive data correct which is more than
0x7F, in that case it will show up as 0x3F (see picture). I have been using different computers, comports
and different software and the Developer Terminal in C# and VB can only show data up to 0x7F correct.

Other terminal software works fine (see picture) including Smiley Terminal Alpha found on your website.
Am I totally stupid, is there a trick or is it a bug?
(could it be Swedish XP version?)

 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
brberie
PostPosted: Apr 28, 2007 - 03:13 PM
Resident


Joined: Sep 12, 2003
Posts: 529
Location: XX century

Just a suggestion: in my version I have "send" and "receive" windows separated.


Last edited by brberie on Apr 28, 2007 - 06:41 PM; edited 1 time in total
 
 View user's profile Send private message  
Reply with quote Back to top
Lennart
PostPosted: Apr 28, 2007 - 03:42 PM
Raving lunatic


Joined: Oct 29, 2006
Posts: 2758
Location: Sweden

Very nice project, now I just have no excuse for starting to send things from my AVR's to PC.
Quote:
I couldn't get the .exe files (how did you get multiple copies in those zip archives?) to run on XP, either the C# or VB ones. Probably something duh-mb I'm doing wrong? I

After looking in many folders and clicking non-working .exe files I found one that worked in:
Developer Term C#\bin\Debug folder.
 
 View user's profile Send private message  
Reply with quote Back to top
smileymicros
PostPosted: Apr 28, 2007 - 04:02 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

Jonil wrote:
Smiley, thanks for answer, I will try myself this weekend.

However, I found an error while receiving data. I cannot receive data correct which is more than
0x7F, in that case it will show up as 0x3F (see picture). I have been using different computers, comports
and different software and the Developer Terminal in C# and VB can only show data up to 0x7F correct.

Other terminal software works fine (see picture) including Smiley Terminal Alpha found on your website.
Am I totally stupid, is there a trick or is it a bug?
(could it be Swedish XP version?)


This looks like a weird bug. I opened two instances of Developer Terminal and they would send and receive values above 0x7F then I opened Brays and it would only show 7F for values above 7F, then I reopened a second instance of Developer and now it will only show 7F for any value above 7F.

Great catch though, and I'll spend time today trying to figure out what is happening. I'm guessing omething is causing the transmission to revert to pure 7-bit ASCII rather than 8-bit bytes.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
smileymicros
PostPosted: Apr 28, 2007 - 04:03 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

brberie wrote:
Just a suggestion: in my version I have "send" and "receive" windows separated.


What language is yours written in and where can I find the source code?

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
AllN
PostPosted: Apr 28, 2007 - 04:37 PM
Posting Freak


Joined: Feb 14, 2007
Posts: 1858
Location: San Diego California

Great job Smiley! This will teach me to ask Smiley first, write later. I just finished the same project. I thought in order to get the source code I would have to write it myself to teach some kids that needed one. Well, in the old days this was true. Keep forgetting there are millions more programmers out there now.
Next time I’m going to just ask Smiley and you will in no uncertain terms tell me where to go. Thanks for all you do!
Cheer,
John
PS I’ll check out your program as soon as I get back home. But I can tell from the screen shots it’s already got it all.

_________________
Resistance is futile…… You will be compiled!
 
 View user's profile Send private message  
Reply with quote Back to top
smileymicros
PostPosted: Apr 28, 2007 - 05:39 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

AllN wrote:
Great job Smiley! This will teach me to ask Smiley first, write later. I just finished the same project. I thought in order to get the source code I would have to write it myself to teach some kids that needed one. Well, in the old days this was true. Keep forgetting there are millions more programmers out there now.
Next time I’m going to just ask Smiley and you will in no uncertain terms tell me where to go. Thanks for all you do!
Cheer,
John
PS I’ll check out your program as soon as I get back home. But I can tell from the screen shots it’s already got it all.


There is no good reason for you not to start a thread on your terminal if you want to share the code since everyone interested in this topic can learn from a different take on the same subject.

Mine will have bugs - so if you will take a look at the code and compare your methods with mine and make your observations public, it would be helpful.

Also, note that if you want something for High-School kids, I've posted a Simple Terminal in the Tutorial forum that is much, well, simpler than this one. I've also got VB code for that terminal if anyone needs it. I may update that tutorial later.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
brberie
PostPosted: Apr 28, 2007 - 06:34 PM
Resident


Joined: Sep 12, 2003
Posts: 529
Location: XX century

smileymicros wrote:
brberie wrote:
Just a suggestion: in my version I have "send" and "receive" windows separated.


What language is yours written in and where can I find the source code?

Smiley

Borland C++ Builder 6.0
I don't have ownership over the source code...
http://sourceforge.net/project/shownotes.php?release_id=160356
 
 View user's profile Send private message  
Reply with quote Back to top
smileymicros
PostPosted: Apr 28, 2007 - 11:50 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

smileymicros wrote:
Jonil wrote:
Smiley, thanks for answer, I will try myself this weekend.

However, I found an error while receiving data. I cannot receive data correct which is more than
0x7F, in that case it will show up as 0x3F (see picture). I have been using different computers, comports
and different software and the Developer Terminal in C# and VB can only show data up to 0x7F correct.

Other terminal software works fine (see picture) including Smiley Terminal Alpha found on your website.
Am I totally stupid, is there a trick or is it a bug?
(could it be Swedish XP version?)


This looks like a weird bug. I opened two instances of Developer Terminal and they would send and receive values above 0x7F then I opened Brays and it would only show 7F for values above 7F, then I reopened a second instance of Developer and now it will only show 7F for any value above 7F.

Great catch though, and I'll spend time today trying to figure out what is happening. I'm guessing omething is causing the transmission to revert to pure 7-bit ASCII rather than 8-bit bytes.

Smiley


This was a byte reception bug that required me to make some changes that are in the new files labeled Beta r02.

Jonil - Major thanks for this catch Very Happy I'd like to send you a Butterfly if you will contact me at my smileymicros email with your address.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
js
PostPosted: Apr 29, 2007 - 12:48 AM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20390
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

hmmmm no function keys as requested by me, I want my money back Smile sorry folks but without functions keys a terminal program is of not much use to me in everyday use.
Haven't used VB for about a year now and even forgot how to load up the source file Laughing it's all coming back so I may have a play at adding some banks of function keys.

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
smileymicros
PostPosted: Apr 29, 2007 - 01:48 AM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

js wrote:
hmmmm no function keys as requested by me, I want my money back Smile sorry folks but without functions keys a terminal program is of not much use to me in everyday use.
Haven't used VB for about a year now and even forgot how to load up the source file Laughing it's all coming back so I may have a play at adding some banks of function keys.


At the end of the Developer Terminal pdf file is a list of features requested in the Freaks thread, those that were included and those that weren't. I don't see 'function keys' so maybe I missed your request. What are you asking for and why wouldn't a macro do?

I might consider an upgrade, but I'll have to double the price.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
AllN
PostPosted: Apr 29, 2007 - 01:52 AM
Posting Freak


Joined: Feb 14, 2007
Posts: 1858
Location: San Diego California

Thanks, when I get a chance I will post the differences especially if I can make it a class also. Funny that’s what they needed it in was basic. The hardest part was getting my head back into Visual Basic, as it has been a long time since a client required it. But it came right back and except for still trying to use pointers in my basic code.

I wrote mine and had the class running in two days (really)!
How long did it take you?
(Sounds like a test or challenge to me, John and you know you just kludged this together it’s a piece of junk. I’d be embarrassed!)
Shut-up! Ignore him Smiley!!!
Thanks for the info on the simple terminal but we are past that hurdle and are conversing with their robot and about to begin exploring mapping its environment with GPS for the rough section map and X/Y matrix down to .25 inches. The only part we are actually adding to one of my existing programs is the higher resolution .25” map for the X/Y plane.

smileymicros wrote:
Jonil wrote:
Thank you for a great software, I've been using the old C# version for a while and it's working fine.
A question, is there a way to invert the data received and get the LSB first, for example if received 0x5B print out 0x25 (called inverse convention)?


Thanks to the miracle of open source, the good news is "YES! You too can send reversed or inverted or any other kind of manipulated byte you can dream up... " The bad news is that you have to do it yourself. I will make myself a note to look at C# this weekend and see if there is a simple equivalent to a rotate or shift. This will probably be a bear in VB, but we'll see. If you figure this out before I get a chance, please post your solution.

Smiley


I extracted this from one of my old programs that should help! I through together a test program that should give you the idea as well as convert any Decimal, Hex, Octal, or Binary number to each equivalent. Don't forget to press return after you enter a number thats what fires the event that displays the values!
Make note it returns a 32 bit binary but you could then just use the VB Mid and the StrReverse reverse commands to shift and rotate!
Hope this helps!
This is a lot of code for a shift, sorry basic!

1) Create a blank form in Visual Basic.
2) Add four text boxes, Named:
a. txtDecimal
b. txtHexadecimal
c. txtOctal
d. txtBinary
3) Then simply past this code in the code space for the form.
4) Input a Hex # in the following format “&H5B” as I have little data checking going on.
5) It displays a 32 bit binary # with 8 Bits separated by spaces. To remove the spaces simply add False to all of the Long2Binary(lValue) functions EG: Long2Binary(lValue, False) and no more spaces.
6) Have fun!
Hope this helps,
John

Ps:
By the way out of fairness Smiley I have to mention, my days are like dog years. Two days for me is actually 40 hours as I rarely sleep more than 4 hrs a night once I’m All In.
(I’ll bet my code is shorter than yours! Hehehe)
Ignore him, Really!
---------------------------------------------------------------
Code:

Option Explicit
Dim mDontRecurse As Boolean

Private Sub Form_Load()
    mDontRecurse = False
End Sub

Private Sub txtBinary_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then DisplayValue txtBinary ',False

End Sub

Private Sub txtDecimal_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then DisplayValue txtDecimal ',False
End Sub

Private Sub txtHexadecimal_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then DisplayValue txtHexadecimal ',False

End Sub

Private Sub txtOctal_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then DisplayValue txtOctal ', False

End Sub

'-Displays values for Dec, Hex, Oct, and 32 Bit Binary
Private Sub DisplayValue(ByVal source As TextBox)
Dim sTmp As String
Dim lValue As Long
   
    ' Don't recurse.
    If mDontRecurse Then Exit Sub
    mDontRecurse = True

    ' Get the Value.
    On Error Resume Next
    Select Case source.Name
        Case "txtDecimal"
            lValue = CLng(source.Text)
        Case "txtHexadecimal"
            sTmp = UCase$(Trim$(source.Text))
            If Left$(sTmp, 2) <> "&H" Then sTmp = "&H" & sTmp
            lValue = CLng(sTmp)
        Case "txtOctal"
            sTmp = UCase$(Trim$(source.Text))
            If Left$(sTmp, 2) <> "&O" Then sTmp = "&O" & sTmp
            lValue = CLng(sTmp)
        Case "txtBinary"
            lValue = Binary2Long(source.Text)
    End Select
    On Error GoTo 0

    ' Display the lValue in their different formats.
    If source.Name <> "txtDecimal" Then
        txtDecimal.Text = Format$(lValue)
    End If
    If source.Name <> "txtHexadecimal" Then
        txtHexadecimal.Text = "&H" & Hex$(lValue)
    End If
    If source.Name <> "txtOctal" Then
        txtOctal.Text = "&O" & Oct$(lValue)
    End If
    If source.Name <> "txtBinary" Then
        txtBinary.Text = Long2Binary(lValue)
    End If

    mDontRecurse = False
End Sub
 

'Converts this 32 bit binary value into a Long.
Private Function Binary2Long(ByVal sBinaryValue As String) As Long
Dim sHexValue As String
Dim iNibble As Integer
Dim iNibbleValue As Integer
Dim iFactor As Integer
Dim iBit As Integer

    ' Remove any leading &B if present.
    ' (Note: &B is not a standard prefix, it just
    ' makes some sense.)
    sBinaryValue = UCase$(Trim$(sBinaryValue))
    If Left$(sBinaryValue, 2) = "&B" Then sBinaryValue = Mid$(sBinaryValue, 3)

    ' Strip out spaces in case the bytes are separated
    ' by spaces.
    sBinaryValue = Replace(sBinaryValue, " ", "")

    ' Left pad with zeros so we have a full 32 bits.
    sBinaryValue = Right$(String(32, "0") & sBinaryValue, 32)

    ' Read the bits in nibbles from right to left.
    ' (A nibble is half a byte. No kidding!)
    For iNibble = 7 To 0 Step -1
        ' Convert this nibble into a hexadecimal string.
        iFactor = 1
        iNibbleValue = 0

        ' Read the nibble's bits from right to left.
        For iBit = 3 To 0 Step -1
            If Mid$(sBinaryValue, 1 + iNibble * 4 + iBit, 1) = "1" Then
                iNibbleValue = iNibbleValue + iFactor
            End If
            iFactor = iFactor * 2
        Next iBit

        ' Add the nibble's value to the left of the
        ' result hex string.
        sHexValue = Hex$(iNibbleValue) & sHexValue
    Next iNibble

    ' Convert the result string into a long.
    Binary2Long = CLng("&H" & sHexValue)
End Function
 
 
 ' Converts this Long value into a 32 bit binary string.
Private Function Long2Binary(ByVal lValue As Long, _
    Optional ByVal bSeparateBinary As Boolean = True) As String
Dim sHex As String
Dim iDigit As Integer
Dim iDigitValue As Integer
Dim sNibble As String
Dim sResult As String
Dim iFactor As Integer
Dim iBit As Integer

    ' Convert into hex.
    sHex = Hex$(lValue)

    ' Zero-pad to a full 8 characters.
    sHex = Right$(String$(8, "0") & sHex, 8)

    ' Read the hexadecimal digits
    ' one at a time from right to left.
    For iDigit = 8 To 1 Step -1
        ' Convert this hexadecimal digit into a
        ' binary nibble.
        iDigitValue = CLng("&H" & Mid$(sHex, iDigit, 1))

        ' Convert the value into bits.
        iFactor = 1
        sNibble = ""
        For iBit = 3 To 0 Step -1
            If iDigitValue And iFactor Then
                sNibble = "1" & sNibble
            Else
                sNibble = "0" & sNibble
            End If
            iFactor = iFactor * 2
        Next iBit

        ' Add the nibble's string to the left of the
        ' result string.
        sResult = sNibble & sResult
    Next iDigit

    ' Add spaces between bytes if desired.
    If bSeparateBinary Then
        sResult = Mid$(sResult, 1, 8) & " " & _
                  Mid$(sResult, 9, 8) & " " & _
                  Mid$(sResult, 17, 8) & " " & _
                  Mid$(sResult, 25, 8)
    End If

    Long2Binary = sResult
   
End Function


'Edited: I get no respect. Even my code laughs at me!

_________________
Resistance is futile…… You will be compiled!


Last edited by AllN on Apr 29, 2007 - 03:48 AM; edited 2 times in total
 
 View user's profile Send private message  
Reply with quote Back to top
AllN
PostPosted: Apr 29, 2007 - 02:03 AM
Posting Freak


Joined: Feb 14, 2007
Posts: 1858
Location: San Diego California

That didn't work!
It changes the formatting to smiley faces!
How do I download a file?
Until then if you need a copy PM me with your email address and I will send it to you!
John

Edited: I get no respect. Even my code laughs at me!

_________________
Resistance is futile…… You will be compiled!
 
 View user's profile Send private message  
Reply with quote Back to top
zbaird
PostPosted: Apr 29, 2007 - 03:22 AM
Raving lunatic


Joined: Aug 13, 2006
Posts: 6707
Location: Bellingham, WA - USA

Quote:
I may have a play at adding some banks of function keys.

If you overdraw at the function key bank does your keyboard bounce?

_________________
Chuck Baird
"It's better to catch the trapeze than test the safety net" -- RPi book
http://www.cbaird.org
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
AllN
PostPosted: Apr 29, 2007 - 03:30 AM
Posting Freak


Joined: Feb 14, 2007
Posts: 1858
Location: San Diego California

zbaird wrote:
Quote:
I may have a play at adding some banks of function keys.

If you overdraw at the function key bank does your keyboard bounce?


I'll bet it does. Twice at least and Microsoft will bill you for it!
Cheers,
John

_________________
Resistance is futile…… You will be compiled!
 
 View user's profile Send private message  
Reply with quote Back to top
smileymicros
PostPosted: Apr 29, 2007 - 03:32 AM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

AllN wrote:

' Add spaces between bytes if desired.
If bSeparateBinary Then
sResult = Mid$(sResult, 1, Cool & " " & _
Mid$(sResult, 9, Cool & " " & _
Mid$(sResult, 17, Cool & " " & _
Mid$(sResult, 25, Cool
End If

Long2Binary = sResult

End Function


'Edited: I get no respect. Even my code laughs at me!


By using the Code button you get:
Code:

    ' Add spaces between bytes if desired.
    If bSeparateBinary Then
        sResult = Mid$(sResult, 1, 8) & " " & _
                  Mid$(sResult, 9, 8) & " " & _
                  Mid$(sResult, 17, 8) & " " & _
                  Mid$(sResult, 25, 8)
    End If

    Long2Binary = sResult
   
End Function


'Edited: I get no respect. Even my code laughs at me!



And the code stops laughing. I can't speak for the rest of us though.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
AllN
PostPosted: Apr 29, 2007 - 03:44 AM
Posting Freak


Joined: Feb 14, 2007
Posts: 1858
Location: San Diego California

OH! That what it for.
Thanks,
John

_________________
Resistance is futile…… You will be compiled!
 
 View user's profile Send private message  
Reply with quote Back to top
AllN
PostPosted: Apr 29, 2007 - 03:58 AM
Posting Freak


Joined: Feb 14, 2007
Posts: 1858
Location: San Diego California

smileymicros wrote:

And the code stops laughing. I can't speak for the rest of us though.

Smiley

Anything that worked is usually fine with me. Can’t tell you how often I get that response from my colleagues after viewing my code. Being an optimist, I always thought I was just a very funny programmer. You don’t think all these years they were laughing at me and I never knew it. Ahh, couldn’t be! Either way I like to make people laugh so that’s OK too.

Cheers,
John
PS:
Tell you what. You always make me laugh! Now all we have to find out is. Is it with you, or at you!
I love this site!!!!

_________________
Resistance is futile…… You will be compiled!
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Apr 29, 2007 - 05:38 AM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20390
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

Quote:
What are you asking for and why wouldn't a macro do?

I guess function keys ARE macros at the end of the day but with buttons attached to them and loadable so that they can be set up and used for different tasks and for different projects.
Do you have hanging around the predecessor to Hyperteminal? It came with Win 3.11 and I use it all the time. Unfortunately it is old with max 19200 baud but it is very handy. The whole program is only 145K so if you would like to play with it and don't have a copy I can post it here. There is also Super Term that has saveable and loadable function keys with the addition that they are actually linked to the keyboard's function keys.
A couple of example of their use is here in my superflasher thread, the keys are set up to talk to Carl's LCD firmware. (both Terminal and Super Term screens)

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=48732&start=60

Here is a page of my interface to the 68HC11EVM to program chips and one to talk to some Omron cardreader for service purposes.

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
js
PostPosted: Apr 29, 2007 - 06:08 AM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20390
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

ps I found the original thread
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=257703
and my comments were:
Quote:
See the 4 buttons you have at the bottom l/h? The old Win 3.11 Terminal program has 4 layers of 8 user programmable function keys which can be saved to a file, so the function for every key (both the key names and what gets sent out) for every project can be saved and reloaded. This for me is the MOST important feature of that old terminal (which I use almost daily).
ohh and the ability to go into a single screen like a real terminal, while I'm wishing VT100 emulation would be nice too with full ANSI support....well you asked for it
...must be discrimination against non C users... Laughing

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Paul Turner
PostPosted: Apr 29, 2007 - 07:45 AM
Wannabe


Joined: Oct 15, 2004
Posts: 69
Location: Australia

Hi, Not wanting to dis' anyone, my source for serial info and code is usually Jan Axelson, have you seen this? http://www.lvr.com/serport.htm#com_port_terminal
Also, I use uCon from here -
http://www.microcross.com/html/micromonitor.html
Much more than HyperTerminal! (Programmable Function keys too!)

_________________
I have coded for about 2 dozen architectures, and they all have their place.
Don't get too religious about them (but AVR is excellent!)
 
 View user's profile Send private message  
Reply with quote Back to top
smileymicros
PostPosted: Apr 29, 2007 - 03:04 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

js wrote:
ps I found the original thread
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=257703
and my comments were:
Quote:
See the 4 buttons you have at the bottom l/h? The old Win 3.11 Terminal program has 4 layers of 8 user programmable function keys which can be saved to a file, so the function for every key (both the key names and what gets sent out) for every project can be saved and reloaded. This for me is the MOST important feature of that old terminal (which I use almost daily).
ohh and the ability to go into a single screen like a real terminal, while I'm wishing VT100 emulation would be nice too with full ANSI support....well you asked for it
...must be discrimination against non C users... Laughing


I totally misunderstood what you wanted! I see now that you want the terminal to respond to non-ASCII keys on the PC keyboard, specifically the function keys like F1 to F12. That is a very good idea and I'll look into it.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
smileymicros
PostPosted: Apr 29, 2007 - 05:47 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

Paul Turner wrote:
Hi, Not wanting to dis' anyone, my source for serial info and code is usually Jan Axelson, have you seen this? http://www.lvr.com/serport.htm#com_port_terminal
Also, I use uCon from here -
http://www.microcross.com/html/micromonitor.html
Much more than HyperTerminal! (Programmable Function keys too!)


I am a great admirer of Jan Axelson's work and anytime anyone asks basic USB questions here, I refer them to her website. I hadn't seen her terminal in .NET and I will look at how she wrote it. It is a much simpler terminal than mine, more like the Simple Terminal I posted a while back.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com


Last edited by smileymicros on Apr 29, 2007 - 07:32 PM; edited 1 time in total
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Jonil
PostPosted: Apr 29, 2007 - 06:41 PM
Wannabe


Joined: Feb 08, 2006
Posts: 62
Location: Sweden

smileymicros wrote:


This was a byte reception bug that required me to make some changes that are in the new files labeled Beta r02.

Jonil - Major thanks for this catch Very Happy I'd like to send you a Butterfly if you will contact me at my smileymicros email with your address.

Smiley


Smiley, thanks for the offer, but I think I have enough toys to play around with.
Better you send me some more time instead Wink

I've been testing the new version and now it's working fine. I will continue to search for bugs but unfortunately I'm quite busy with other things for two weeks.

Thanks for the great work so far.
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
js
PostPosted: Apr 30, 2007 - 12:44 AM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20390
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

@Paul
Quote:
I use uCon from here
Pretty good for my use, I would like MORE programmable buttons, (is there EVER enough? Laughing ) but it has a few more than Superterm. With some projects I can go up to 32 buttons and with the old Terminal one can just switch banks but when the max number is reached then one would need to load up another lot of keys. It is very rare that I need 32 keys though....well at least that's the maximum I could use so far Smile

@Smiley
Quote:
That is a very good idea and I'll look into it.
Adding programmable function buttons is easy enough as you know, the hard thing I could not get my head around with VB was on how to make them saveable and loadable. With Delphi it was just a matter of editing the .ini file where the configuration is saved, not as easy with VB2005 it seems. I asked for help on M$ forum but it looked like one would have to get some database file happening (that's what a .ini file is anyway of some sort) but i could not get my simple head around on how to do it. Simple enough to modify parameters like serial ports etc which are part of the program and get saved automatically by VB on exit. I know you'll get it working...think of the prestige, fame, you will be invited to the White house for dinner with the Bushes..all of them. Not much money though Laughing

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
AllN
PostPosted: May 01, 2007 - 06:16 PM
Posting Freak


Joined: Feb 14, 2007
Posts: 1858
Location: San Diego California

Well I’m back home.
I just installed VB 2005 Express and I will check out your terminal program tonight and compare it if time allows. I imported the Shift Rotate convert VB 6.0 program to VB Express to compare and I must say I like the class layout.
The import sure helps you learn quickly. I like it.
Here is the convert program imported into VB 2005 Express.
Code:
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class Converter
   Inherits System.Windows.Forms.Form
   Dim mDontRecurse As Boolean
   
   Private Sub Converter_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
      mDontRecurse = False
   End Sub
   
   Private Sub txtBinary_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtBinary.KeyPress
      Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
      If KeyAscii = 13 Then DisplayValue(txtBinary) ',False
      
      eventArgs.KeyChar = Chr(KeyAscii)
      If KeyAscii = 0 Then
         eventArgs.Handled = True
      End If
   End Sub
   
   Private Sub txtDecimal_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtDecimal.KeyPress
      Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
      If KeyAscii = 13 Then DisplayValue(txtDecimal) ',False
      eventArgs.KeyChar = Chr(KeyAscii)
      If KeyAscii = 0 Then
         eventArgs.Handled = True
      End If
   End Sub
   
   Private Sub txtHexadecimal_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtHexadecimal.KeyPress
        Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
        If KeyAscii = 13 Then DisplayValue(txtHexadecimal)
      
      eventArgs.KeyChar = Chr(KeyAscii)
      If KeyAscii = 0 Then
         eventArgs.Handled = True
      End If
   End Sub
   
   Private Sub txtOctal_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtOctal.KeyPress
      Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
        If KeyAscii = 13 Then DisplayValue(txtOctal)
      
      eventArgs.KeyChar = Chr(KeyAscii)
      If KeyAscii = 0 Then
         eventArgs.Handled = True
      End If
   End Sub
   
   '-Displays values for Dec, Hex, Oct, and 32 Bit Binary
   Private Sub DisplayValue(ByVal source As System.Windows.Forms.TextBox)
      Dim sTmp As String
      Dim lValue As Integer
      
      ' Don't recurse.
      If mDontRecurse Then Exit Sub
      mDontRecurse = True
      
      ' Get the Value.
      On Error Resume Next
      Select Case source.Name
         Case "txtDecimal"
            lValue = CInt(source.Text)
         Case "txtHexadecimal"
            sTmp = UCase(Trim(source.Text))
            If VB.Left(sTmp, 2) <> "&H" Then sTmp = "&H" & sTmp
            lValue = CInt(sTmp)
         Case "txtOctal"
            sTmp = UCase(Trim(source.Text))
            If VB.Left(sTmp, 2) <> "&O" Then sTmp = "&O" & sTmp
            lValue = CInt(sTmp)
         Case "txtBinary"
            lValue = Binary2Long(source.Text)
      End Select
      On Error GoTo 0
      
      ' Display the lValue in their different formats.
      If source.Name <> "txtDecimal" Then
         txtDecimal.Text = VB6.Format(lValue)
      End If
      If source.Name <> "txtHexadecimal" Then
         txtHexadecimal.Text = "&H" & Hex(lValue)
      End If
      If source.Name <> "txtOctal" Then
         txtOctal.Text = "&O" & Oct(lValue)
      End If
      If source.Name <> "txtBinary" Then
         txtBinary.Text = Long2Binary(lValue)
      End If
      
      mDontRecurse = False
   End Sub
   

   
   'Converts this 32 bit binary value into a Long.
   Private Function Binary2Long(ByVal sBinaryValue As String) As Integer
      Dim sHexValue As String
      Dim iNibble As Short
      Dim iNibbleValue As Short
      Dim iFactor As Short
      Dim iBit As Short

        sHexValue = ""
      ' Remove any leading &B if present.
      ' (Note: &B is not a standard prefix, it just
      ' makes some sense.)
      sBinaryValue = UCase(Trim(sBinaryValue))
      If VB.Left(sBinaryValue, 2) = "&B" Then sBinaryValue = Mid(sBinaryValue, 3)
      
      ' Strip out spaces in case the bytes are separated
      ' by spaces.
      sBinaryValue = Replace(sBinaryValue, " ", "")
      
      ' Left pad with zeros so we have a full 32 bits.
      sBinaryValue = VB.Right(New String("0", 32) & sBinaryValue, 32)
      
      ' Read the bits in nibbles from right to left.
      ' (A nibble is half a byte. No kidding!)
      For iNibble = 7 To 0 Step -1
         ' Convert this nibble into a hexadecimal string.
         iFactor = 1
         iNibbleValue = 0
         
         ' Read the nibble's bits from right to left.
         For iBit = 3 To 0 Step -1
            If Mid(sBinaryValue, 1 + iNibble * 4 + iBit, 1) = "1" Then
               iNibbleValue = iNibbleValue + iFactor
            End If
            iFactor = iFactor * 2
         Next iBit
         
         ' Add the nibble's value to the left of the
         ' result hex string.
         sHexValue = Hex(iNibbleValue) & sHexValue
      Next iNibble
      
      ' Convert the result string into a long.
      Binary2Long = CInt("&H" & sHexValue)
   End Function
   
   
   
   
   ' Converts this Long value into a 32 bit binary string.
   Private Function Long2Binary(ByVal lValue As Integer, Optional ByVal bSeparateBinary As Boolean = True) As String
      Dim sHex As String
      Dim iDigit As Short
      Dim iDigitValue As Short
      Dim sNibble As String
      Dim sResult As String
      Dim iFactor As Short
      Dim iBit As Short

        sResult = ""
      ' Convert into hex.
      sHex = Hex(lValue)
      
      ' Zero-pad to a full 8 characters.
      sHex = VB.Right(New String("0", 8) & sHex, 8)
      
      ' Read the hexadecimal digits
      ' one at a time from right to left.
      For iDigit = 8 To 1 Step -1
         ' Convert this hexadecimal digit into a
         ' binary nibble.
         iDigitValue = CInt("&H" & Mid(sHex, iDigit, 1))
         
         ' Convert the value into bits.
         iFactor = 1
         sNibble = ""
         For iBit = 3 To 0 Step -1
            If iDigitValue And iFactor Then
               sNibble = "1" & sNibble
            Else
               sNibble = "0" & sNibble
            End If
            iFactor = iFactor * 2
         Next iBit
         
         ' Add the nibble's string to the left of the
         ' result string.
         sResult = sNibble & sResult
      Next iDigit
      
      ' Add spaces between bytes if desired.
      If bSeparateBinary Then
         sResult = Mid(sResult, 1, 8) & " " & Mid(sResult, 9, 8) & " " & Mid(sResult, 17, 8) & " " & Mid(sResult, 25, 8)
      End If
      
      Long2Binary = sResult
      
   End Function
End Class

Cheers,
John

_________________
Resistance is futile…… You will be compiled!
 
 View user's profile Send private message  
Reply with quote Back to top
AllN
PostPosted: May 02, 2007 - 01:24 AM
Posting Freak


Joined: Feb 14, 2007
Posts: 1858
Location: San Diego California

smileymicros wrote:
... so if you will take a look at the code and compare your methods with mine and make your observations public, it would be helpful.
Smiley


Well they are about the same. Not the functions or functionality. Yours is much more suited for the Butterfly and embedded systems in general, as your understanding is far ahead of mine. But they both essentially use a serial Comm event to process data. You use one timer1 to set showCTS_DSR_CD so do I. But I use a 2nd timer to clear some error messages when they occur.
Now the launguage comparsion VB 6.0 to VB Express.
It takes a lot longer to step through someone elses code in VB Express. You step through everything the from class and buttion definition, everything.
If you’re any kind of object oriented programmer I think you’ll aggree Express would probally be easier to learn. If you had to learn basic.
If this is the first laungauge your learning seems it’s not quite as basic or as easy for a true beginner.
For 1st timers I belive VB 6.0 would be eaiser. But you should never go backwards. So just learn C, C+, C++, or C#. You’ll be further head in the long run.
PS:
Here is my comm Event and Textbox keypress event that does all of the work.
Code:

Private Static Sub CommModem3_OnComm()
Dim EVMsg$, ERMsg$, iRslt%
Dim buffer As Variant
   
    ' Branch according to the CommEvent property.
    Select Case CommModem3.CommEvent
        ' Event messages.
        Case comEvReceive
     
            buffer = CommModem3.Input
            Debug.Print "Receive - " & StrConv(buffer, vbUnicode)
            ShowData txtTermRX, (StrConv(buffer, vbUnicode))
           
            gdReceived = gdReceived + Len(StrConv(buffer, vbUnicode))
            If Timer2.Enabled = False Then
                sbrStatus.Panels("Status").Text = gdReceived & " Rec'd"
            End If
           
        Case comEvSend
       
        Case comEvCTS
            If imgCtsOff.Visible = True Then
                imgCtsOff.Visible = False
            Else
                imgCtsOff.Visible = True
            End If
            EVMsg$ = "Change in CTS Detected"
           
        Case comEvDSR
            If imgDsrOff.Visible = True Then
                imgDsrOff.Visible = False
            Else
                imgDsrOff.Visible = True
            End If
            EVMsg$ = "Change in DSR Detected"
        Case comEvCD
            If imgCdOff.Visible = True Then
                imgCdOff.Visible = False
            Else
                imgCdOff.Visible = True
            End If
            EVMsg$ = "Change in CD Detected"
        Case comEvRing
            If imgRiOff.Visible = True Then
                imgRiOff.Visible = False
            Else
                imgRiOff.Visible = True
            End If
            EVMsg$ = "The Phone is Ringing"
        Case comEvEOF
            EVMsg$ = "End of File Detected"

        ' Error messages.
        Case comBreak
            ERMsg$ = "Break Received"
        Case comCDTO
            ERMsg$ = "Carrier Detect Timeout"
        Case comCTSTO
            ERMsg$ = "CTS Timeout"
        Case comDCB
            ERMsg$ = "Error retrieving DCB"
        Case comDSRTO
            ERMsg$ = "DSR Timeout"
        Case comFrame
            ERMsg$ = "Framing Error"
        Case comOverrun
            ERMsg$ = "Overrun Error"
        Case comRxOver
            ERMsg$ = "Receive Buffer Overflow"
        Case comRxParity
            ERMsg$ = "Parity Error"
        Case comTxFull
            ERMsg$ = "Transmit Buffer Full"
        Case Else
            ERMsg$ = "Unknown error or event"
    End Select
   
    If Len(EVMsg$) Then
        ' Display event messages in the status bar.
        sbrStatus.Panels("Status").Text = "Status: " & EVMsg$
               
        ' Enable timer so that the message in the status bar
        ' is cleared after 2 seconds
        Timer2.Enabled = True
       
    ElseIf Len(ERMsg$) Then
        ' Display event messages in the status bar.
        sbrStatus.Panels("Status").Text = "Status: " & ERMsg$
       
        ' Display error messages in an alert message box.
        Beep
       iRslt = MsgBox(ERMsg$, 1, "Click Cancel to quit, OK to ignore.")
       
        ' If the user clicks Cancel (2)...
        If iRslt = 2 Then
            CommModem3.PortOpen = False    ' Close the port and quit.
        End If
       
        ' Enable timer so that the message in the status bar
        ' is cleared after 2 seconds
        Timer2.Enabled = True
    End If
End Sub

' Keystrokes trapped here are sent to the MSComm
' control where they are echoed back via the
' OnComm (comEvReceive) event, and displayed
' with the ShowData procedure.
Private Sub txtTermRX_KeyPress(KeyAscii As Integer)
    ' If the port is opened...
    If CommModem3.PortOpen Then
        ' Send the keystroke to the port.
        CommModem3.Output = Chr$(KeyAscii)

        ' Unless gbEcho is on, there is no need to
        ' let the text control display the key.
        ' A modem usually echos back a character
        If Not gbEcho(3) Then
            ' Place position at end of terminal
            txtTermRX.SelStart = Len(txtTermRX)
            KeyAscii = 0
        End If
    End If
     
End Sub


Hope this helps
Learn C
Cheers,
John

_________________
Resistance is futile…… You will be compiled!
 
 View user's profile Send private message  
Reply with quote Back to top
danielson
PostPosted: May 19, 2007 - 08:55 PM
Wannabe


Joined: Jun 28, 2001
Posts: 75


I think I found a bug...

I've noticed with non-ASCII data that it doesn't always
get displayed as its received. I've tested it minimally but it seems to stay in queue only to be displayed the next time data is received...and if that data is non-standard (example, contains NULLs, maybe no new-line character)... it is also truncated and the end-result that you're always missing some data..

I tested with a cool but unbelievably-crippled program ("RS232 Hex Comm Demo") and it works great.

Also, something it does that I love, if you're interested is...in ascii mode, it displays ascii and then hex characters inside paranthesis... This could be confusing of course if your MCU is sending like (01) back in ASCII, but you can figure how to format the hex display...

All in all though, a pretty-sweet and useful program. I've been using it to develop a packet-engine for MCU to MCU communication over a half-duplex, bi-directional UART
 
 View user's profile Send private message  
Reply with quote Back to top
smileymicros
PostPosted: Feb 18, 2008 - 03:08 AM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

Well this thing is getting a bit long in the tooth, but I was using it today and realized that I never fixed the bug about not sending values > 0x7F. After most of a day futzing with it I found that the SerialPort class defaults to ASCIIEncoding so when you try to send anything > 0x7F it sends 0x3F instead. Since the 0x#F is ASCII for '?' I guess I should have gotten a clue sooner.

Anyway, the fix is:
Code:

    // JWP 2/17/08 Set encoding to 8 bits - was ASCII
    serialPort1.Encoding = System.Text.Encoding.UTF8;

Just add this line at the beginning of the MainForm class.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
PaulCo
PostPosted: Apr 01, 2008 - 08:43 AM
Newbie


Joined: Jan 03, 2008
Posts: 11


major thanks
just what i needed
PaulCo
 
 View user's profile Send private message  
Reply with quote Back to top
dav1dr4y
PostPosted: Mar 29, 2010 - 08:44 PM
Newbie


Joined: Jan 22, 2010
Posts: 3
Location: Texas

Guess I am kind of late to the party. I have been working my way through Workshops from late last year through the current ones. On Windows 7, both 64 bit and 32 bit, both Simple Terminal and Developer Terminal did not list any ports in the Setting dialog. I made the following change in both GetCOM and GetPorts in the PortSettings Class (C# code)
Code:
//string[] strArray = DevInfo.DeviceInfo.ParsePorts();
string[] strArray = SerialPort.GetPortNames();

I realize this uses the SerialPort class that Smiley says does not work right. It seems to be working for me whereas the DeviceInfo class did not work at all.

Not sure what is different. I have had this experience on two different Windows 7 machines. I am using MS Visual C# 2008 Express. I have .NET 2.0 SP2 and .NET 3.5 SP1.

I enjoy and appreciate this program and the Workshops! Mr. Green

Thanks,
David Cool
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
smileymicros
PostPosted: Mar 29, 2010 - 11:44 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

The original SerialPort.GetPortNames() class would read ports from the registry and if you had a couple of ports open and your system crashed, then the only way you could get them off your list was uh... I don't remember... but it was a PITA so I used the other method which actually looked to see what posts were really open.

They may have changed it by now, but if you start seeing ports that aren't actually there, then maybe my hints will help figure it out.

Just as an aside, I spent a couple of hours yesterday trying to figure out why my C# 2008 would not publish a program and kept telling me that my signing certificate had expired. I've never used a signing certificate and the Googling came up with a lot of very misleading and confusing solutions. I eventually figured out that one of the updates in either Studio or .NET had kindly checked a box in my project properties that told the OneClick (or whatever the name is) publish routine to check the certificate. When I unchecked it then it published okay.

BTW, thanks for the nice words.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits