Click here to Skip to main content
15,923,376 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: block / unblock application Pin
Dave Kreskowiak18-Aug-07 2:59
mveDave Kreskowiak18-Aug-07 2:59 
GeneralRe: block / unblock application Pin
Rupesh Kumar Swami19-Aug-07 22:32
Rupesh Kumar Swami19-Aug-07 22:32 
GeneralRe: block / unblock application Pin
Dave Kreskowiak20-Aug-07 1:59
mveDave Kreskowiak20-Aug-07 1:59 
Questionhow to download mails from server to local machine. Pin
rahul.net1117-Aug-07 20:26
rahul.net1117-Aug-07 20:26 
AnswerRe: how to download mails from server to local machine. Pin
MidwestLimey18-Aug-07 10:43
professionalMidwestLimey18-Aug-07 10:43 
QuestionHow to Get Dynamic Help using using Ctrl+F1 for VBA APIs Pin
Jahnson K17-Aug-07 10:33
Jahnson K17-Aug-07 10:33 
Questionvb.net serialport class transmission problem [modified] Pin
Cory Kimble17-Aug-07 6:50
Cory Kimble17-Aug-07 6:50 
AnswerRe: vb.net serialport class transmission problem [modified] Pin
Luc Pattyn17-Aug-07 7:22
sitebuilderLuc Pattyn17-Aug-07 7:22 
Hi Cory,

I have several remarks:

1.
readcollect(0).ToString <> "79" is terrible code; if you mean character O
then write that, nothing else; if you want to compare characters, then do that,
nothing else. Hence: readcollect(0) <> "O"c

2.
Your serialPort.IsOpen test is inside the while loop, so if it fails, you will
never exit the loop??? Either you know the port is open, so you don't need the
test, or you don't know and you test once, outside the loop, and if the test
fails you take appropriate action (such as return an error code, or throw an
exception, but not hang your thread in an infinite loop).

3.
serialPort.Read(readcollect, 0, 1).ToString()
Read returns an int, why would you convert it to string and then ignore it?
And more importantly, why do you ignore a significant return value, that tells
you how many chars/bytes have been read ?

4.
I don't think it is wise to create a loop that transmits data without any rest;
if it fails the first time, it will very likely continue to fail. At least
include some throttling, such as a Trhead.Sleep(1000) or so (i.e. trying
once per second).

5.
If you send once, the reply will not be there immediately; it takes a while for
the characters to be transmitted, then received on the other side, interpreted,
understood, reacted upon, reply transmitted, then received and be ready for
the Read() method. In the mean time the PC is long past it's first Read
attempt. That's another reason to have a Sleep just after the Write, I would
use 100 msec for starters.

6.
a serial read may fail to return chars/bytes for one of many reasons, such as:
- cable disconnected
- nothing was sent by the other party
- dataflow has disabled communication (XOFF char, control line has wrong polarity)
- all chars received have been rejected (e.g. because they are NULL, or
equal to newline terminator, wrong baudrate/parity/bitcount, ...)

7.
a serial write may fail to transmit chars/bytes for a couple of reasons, they
are fewer as the previous list; the main reason is your side is told not to
transmit, i.e. dataflow control prevents transmission because XOFF was received
or control lines have wrong polarity (depends on SerialPort.HandShake).


My best guess is you are transmitting but you are not receiving. You can check this
by using a null modem cable (which has two female connectors) and connect
either another port of same PC, or another PC, instead of your current target;
then use a terminal emulator (such as HyperTerminal) on that port or PC.
BTW: you'd better have that Sleep included if you want to be able to read
what HyperTerminal receives...

Smile | :)






-- modified at 13:28 Friday 17th August, 2007

Luc Pattyn [Forum Guidelines] [My Articles]


this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google


GeneralRe: vb.net serialport class transmission problem Pin
Cory Kimble17-Aug-07 9:05
Cory Kimble17-Aug-07 9:05 
GeneralRe: vb.net serialport class transmission problem Pin
Luc Pattyn17-Aug-07 9:34
sitebuilderLuc Pattyn17-Aug-07 9:34 
QuestionProgress Bar Pin
jds120717-Aug-07 5:40
jds120717-Aug-07 5:40 
AnswerRe: Progress Bar Pin
Dave Kreskowiak17-Aug-07 6:40
mveDave Kreskowiak17-Aug-07 6:40 
AnswerRe: Progress Bar Pin
koolprasad200317-Aug-07 20:17
professionalkoolprasad200317-Aug-07 20:17 
QuestionREGEX issue Pin
ant1xxx17-Aug-07 5:04
ant1xxx17-Aug-07 5:04 
GeneralRe: REGEX issue Pin
Guffa17-Aug-07 7:47
Guffa17-Aug-07 7:47 
QuestionOpen / Convert .DBF file [modified] Pin
New_Coder17-Aug-07 4:06
New_Coder17-Aug-07 4:06 
AnswerRe: Open / Convert .DBF file Pin
Vasudevan Deepak Kumar17-Aug-07 4:37
Vasudevan Deepak Kumar17-Aug-07 4:37 
GeneralRe: Open / Convert .DBF file Pin
New_Coder17-Aug-07 4:52
New_Coder17-Aug-07 4:52 
Questionconnecting to sql server in network environment Pin
raaman17-Aug-07 3:57
raaman17-Aug-07 3:57 
AnswerRe: connecting to sql server in network environment Pin
Dave Kreskowiak17-Aug-07 4:19
mveDave Kreskowiak17-Aug-07 4:19 
QuestionSetSystemTime() Pin
VIP-CoMmAnDo17-Aug-07 0:28
VIP-CoMmAnDo17-Aug-07 0:28 
AnswerRe: SetSystemTime() Pin
Luc Pattyn17-Aug-07 1:52
sitebuilderLuc Pattyn17-Aug-07 1:52 
GeneralRe: SetSystemTime() Pin
VIP-CoMmAnDo17-Aug-07 4:03
VIP-CoMmAnDo17-Aug-07 4:03 
Generalnot DWORD Pin
Luc Pattyn17-Aug-07 4:28
sitebuilderLuc Pattyn17-Aug-07 4:28 
AnswerRe: SetSystemTime() Pin
Dave Kreskowiak17-Aug-07 4:25
mveDave Kreskowiak17-Aug-07 4:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.