Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 4th, 2008, 09:47 PM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Making serial comm work with SerialPort

I am new to .NET and have tried to convert an existing working VB6 application over to 2008 VB.NET. For the most part, everything is OK and workable but the fundamental COM object is totally different. I need to write a series of Bytes from a buffer using "SerialPort". I have an instance of the object on a form and have checked the instance's properties (called SerialPort1) to be correct - 9600 Baud, 8 bit characters, no handshaking. I am using the following command to send 9 bytes from a command button on the form

SerialPort1.Open()
SerialPort1.Write(OutputBuffer, Offset, 9)
SerialPort1.Close()

The Write routine contains:
Public Sub Write(ByVal buffer As Byte(), ByVal offset As Integer _
ByVal count As Integer)

I am establishing Byte values within the OutputBuffer array that contain numeric values and in debug mode they are there correctly for transmission. It is pretty straightforward but not working. I know the hardware is good as the same app running in VB6 runs fine to the same board on the same PC with the same cable. My .NET code does not generate any errors in design time or run time, but I get no output on the target hardware. the string should light a series of LEDs on the I/O board.

Does anybody have experience in fundamental non-handshaking RS232C serial communications that is doing this or can point me in the right direction?

GMan




Reply With Quote
  #2 (permalink)  
Old March 5th, 2008, 12:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

GMan,

You verified instance's properties are all populated with right values, the object looks in good health.

But tell me is there any specific reason you are using Write instead of WriteLine, you see WriteLine also takes care of the encoding bit of work for you.

Secondly, try calling Close at a later event like at form closing.
Also try making this object global, at times these problems occur cos the object you are calling methods on has already gone out of scope, a case where the handle stays, but application's reference pointer to it is lost.

If nothing works write back with the code snippets from your VB6 app that did work.

Regards
Ankur
Reply With Quote
  #3 (permalink)  
Old March 6th, 2008, 10:19 PM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As usual, if I had another brain, it would be lonesome. I appreciate your help, but found out I made two fundamental mistakes that prevented the routine from working.

1) Whereas I thought the proper sequence consisted of 9 bytes, it needed 10

2) I had an offset value set incorrectly so the bytes sent to SerialPort1 were not proper.

Once these were fixed, the routine worked fine.

Thanks again for taking the time to care enough and respond!!!

Gordon

Reply With Quote
  #4 (permalink)  
Old March 7th, 2008, 05:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

....or that :)

That was quite an expression ;)

You are welcome.

Regards
Ankur
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
making special characters work Brian Campbell XSLT 4 January 10th, 2007 03:43 PM
C++ Serial I/O Comm Library CNewbie C++ Programming 1 November 25th, 2004 02:59 PM
making php work? P.Y.sum Beginning PHP 5 November 5th, 2003 10:28 AM
making an .exe work cooky4 VB Databases Basics 2 June 3rd, 2003 11:31 PM



All times are GMT -4. The time now is 09:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.