Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
AnswerRe: Export from DataGridView to access _ c# Pin
OriginalGriff24-Mar-19 21:10
mveOriginalGriff24-Mar-19 21:10 
GeneralRe: Export from DataGridView to access _ c# Pin
Member 1419439024-Mar-19 22:11
Member 1419439024-Mar-19 22:11 
GeneralRe: Export from DataGridView to access _ c# Pin
OriginalGriff24-Mar-19 22:40
mveOriginalGriff24-Mar-19 22:40 
QuestionQuestion about login form with access database Pin
Member 1114879324-Mar-19 1:42
Member 1114879324-Mar-19 1:42 
AnswerRe: Question about login form with access database Pin
OriginalGriff24-Mar-19 2:03
mveOriginalGriff24-Mar-19 2:03 
QuestionMessage Removed Pin
23-Mar-19 12:08
Member 1419354023-Mar-19 12:08 
QuestionCzytanie z drukarki Posnet / Receive Posnet POS printer answer Pin
OraToraCora21-Mar-19 13:24
OraToraCora21-Mar-19 13:24 
AnswerRe: Czytanie z drukarki Posnet / Receive Posnet POS printer answer Pin
Luc Pattyn21-Mar-19 15:37
sitebuilderLuc Pattyn21-Mar-19 15:37 
Hi,

writing to a serial port is the easy part; reading from it can be much more difficult.

ReadLine() will return only once the line terminator is received; it equals <cr> or <cr><lf> (may depend on your system), or could be whatever your SerialPort.NewLine property has been set to. So if your peripheral never sends the matching terminator, ReadLine will hang indefinitely.

[Added:] ReadLine also only returns a single line of text, so if there is some data (maybe even an empty line, i.e. just a line terminator) already in the Windows buffer, then ReadLine will return that old or empty line...

FYI, I don't trust the defaults of the SerialPort class, I tend to set things explicitly just to make sure they are what I want them to be.

My debug suggestion:

If what the peripheral is expected to send is printable text, then you might experiment with some delay, say Thread.Sleep(1000), followed by ReadExisting(). That would show you what is received in that one second.

If the peripheral speaks in binary code, you must use binary reads, i.e. the Read() method.

Using Thread.Sleep probably doesn't fit well in your application, so the final approach may require something else, probably a separate thread. I often use a BackgroundWorker for dealing with serial input!

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum


modified 21-Mar-19 21:51pm.

GeneralRe: Czytanie z drukarki Posnet / Receive Posnet POS printer answer Pin
glennPattonWork325-Mar-19 6:39
professionalglennPattonWork325-Mar-19 6:39 
QuestionDecimal values input validation Pin
Rap Gutierrez21-Mar-19 2:31
professionalRap Gutierrez21-Mar-19 2:31 
AnswerRe: Decimal values input validation Pin
OriginalGriff21-Mar-19 3:31
mveOriginalGriff21-Mar-19 3:31 
AnswerRe: Decimal values input validation Pin
Member 230317321-Mar-19 21:26
Member 230317321-Mar-19 21:26 
AnswerRe: Decimal values input validation Pin
BillWoodruff22-Mar-19 19:47
professionalBillWoodruff22-Mar-19 19:47 
AnswerRe: Decimal values input validation Pin
jschell23-Mar-19 5:42
jschell23-Mar-19 5:42 
GeneralRe: Decimal values input validation Pin
BillWoodruff23-Mar-19 6:24
professionalBillWoodruff23-Mar-19 6:24 
Questionprogramming Pin
Member 1419026720-Mar-19 12:41
Member 1419026720-Mar-19 12:41 
AnswerRe: programming Pin
Dave Kreskowiak20-Mar-19 15:51
mveDave Kreskowiak20-Mar-19 15:51 
AnswerRe: programming Pin
OriginalGriff20-Mar-19 21:03
mveOriginalGriff20-Mar-19 21:03 
GeneralRe: programming Pin
Ralf Meier20-Mar-19 22:17
mveRalf Meier20-Mar-19 22:17 
GeneralRe: programming Pin
OriginalGriff20-Mar-19 22:23
mveOriginalGriff20-Mar-19 22:23 
GeneralRe: programming Pin
Ralf Meier20-Mar-19 23:32
mveRalf Meier20-Mar-19 23:32 
GeneralRe: programming Pin
OriginalGriff20-Mar-19 23:42
mveOriginalGriff20-Mar-19 23:42 
AnswerRe: programming Pin
jschell23-Mar-19 5:45
jschell23-Mar-19 5:45 
QuestionQuantization the value of HSV Color using Non-equal Intervals Pin
gnjr9720-Mar-19 0:28
gnjr9720-Mar-19 0:28 
AnswerRe: Quantization the value of HSV Color using Non-equal Intervals Pin
OriginalGriff20-Mar-19 0:48
mveOriginalGriff20-Mar-19 0:48 

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.