Rs232 cr & lf?
Rs232 cr & lf?
Rs232 cr & lf?
Rs232 cr & lf?
Rs232 cr & lf?
Rs232 cr & lf? Rs232 cr & lf? Rs232 cr & lf? Rs232 cr & lf? Rs232 cr & lf? Rs232 cr & lf? Rs232 cr & lf? Rs232 cr & lf?
Rs232 cr & lf? Rs232 cr & lf?
Rs232 cr & lf?
Go Back  Xtreme Visual Basic Talk > > > Rs232 cr & lf?


Reply
 
Thread Tools Display Modes
  #1  
Old 04-26-2011, 05:55 AM
Mr Clauds Mr Clauds is offline
Freshman
 
Join Date: Jul 2008
Posts: 32
Default Rs232 cr & lf?


Hey guys

Im using VB2008... Net framework 3.0

Basically I have a barcode scanner that is sending the software data...
Everything is working fine if I interface the scanner as a keyboard wedge and set the scanner suffix as 'Enter'...
In the software I have an event handler on keypress.down...

If keycode.Enter then
.....
.....
....
etc.

However as a RS232 interface I cant get the same result?
Hyper terminal reads it perfectly.
I've tried all the keypress options but it doesnt work (I assume because it's not actually a key press).
Can some one shed some light on simply having the above bit of code work
when the textbox recieves the CR/LF from RS232?

PS. The scanner that does keyboard wedge interfacing is not an option as it is far too expensive for my project

Thanks
Clauds

Last edited by Mr Clauds; 04-26-2011 at 09:02 AM.
Reply With Quote
  #2  
Old 04-26-2011, 09:12 AM
AtmaWeapon's Avatar
AtmaWeaponRs232 cr & lf? AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

I'm assuming if you are using RS232 you're getting bytes as data? Or is it a string?

If it's bytes, look for 13 followed by 10; that's CRLF. Maybe you only get one or the other. Maybe you don't get it at all. Generally when it comes to getting streams of bytes every piece of hardware is different. Your manual should have information.

If it's a string, you can look for CR and LF separately or you can look for them together.

Here's some examples, you'd need to choose one:
Code:
Dim yourString As String = GetStringFromScanner()

If yourString.EndsWith(vbCrLf) Then
    ' The string ends with a CRLF
End If

If yourString.Contains(vbCrLf) Then
    ' The string has a CRLF, but maybe not at the end
End If

Dim cr As Char = Chr(13)
Dim lf As Char = Chr(10)

If yourString.EndsWith(cr) Then
...
If nothing works, you need to tell us more about how you get the data and look for information that defines the protocol.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #3  
Old 04-26-2011, 09:34 AM
mkaras's Avatar
mkarasRs232 cr & lf? mkaras is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Mar 2004
Location: Beaverton, OR
Posts: 1,874
Default

Another option to check what is going on is to simply print out each byte value that comes in the serial port control to the debug window. You can then see what the terminating characters are. (If I was doing this I would format the debug window output in Hex. In Hex a <Cr> is 0x0D and a <Lf> is 0x0A.

Michael Karas
Reply With Quote
  #4  
Old 04-28-2011, 02:10 AM
Mr Clauds Mr Clauds is offline
Freshman
 
Join Date: Jul 2008
Posts: 32
Default

Thanks guys...

Sorry for taking so long to get back...
I used mystring.contains(cr) and it works perfectly...

Thanks

Last edited by Mr Clauds; 04-28-2011 at 06:48 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Rs232 cr &amp; lf?
Rs232 cr &amp; lf?
Rs232 cr &amp; lf? Rs232 cr &amp; lf?
Rs232 cr &amp; lf?
Rs232 cr &amp; lf?
Rs232 cr &amp; lf? Rs232 cr &amp; lf? Rs232 cr &amp; lf? Rs232 cr &amp; lf? Rs232 cr &amp; lf? Rs232 cr &amp; lf? Rs232 cr &amp; lf?
Rs232 cr &amp; lf?
Rs232 cr &amp; lf?
 
Rs232 cr &amp; lf?
Rs232 cr &amp; lf?
 
-->