Send and recieve data using serial connection (PC)


hello,

i making small program ( vb .net) reads usb gamepad input , sends user defined messages (based on button pressed) pc arduino.

the arduino can send messages pc.

now have little problem (or challenge  ;))?

i have made small program sends data arduino pc. message "test" send every second pc. show data in textbox. place every message on new line.

the message send using following command: serial.print("test")

so:
test
test
test

and not:
test test test

the problem this:

t
est
test
te
st


it looks message divided in small packets? normal way? don't know how data send on serial connection?

is there common way send data pc , back? maybe put special piece of code behind every message, like: test<$> . buffer reads <$> ?

you suggestions please.

thanks in advance.

edit: i've tried serial.println("test"); not work.

welcome world of protocols, opensource...

what undoubtedly happening reads on computer happening when complete data isn't in serial buffer on pc.  

you can counteract couple of ways (one touched upon)
1)  pause , control data way, ie send data, wait ten seconds, send data again.
2)  mark end of transmission (end of block, end of line...) pc knows block, line, etc goes which.
3)  mark beginning of transmission
4) mark both beginning , endings.

i marking beginning cases when connecting device already-communicating line.  but, if watch 1 or other, wouldn't clear when first connecting running system.  

you have ensure serial lines quiet, or out of sync , miss part of first packet.  

(imagine starting reading message: don't delete file after plugging in after word 'don't')

here do, simple protocol marking beginning , ending of block:

on arduino:
code: [select]
serial.print("!");
serial.print("something send.\r\n");


on pc, here pseudo code: (i leave code up...)
- check our local data buffer.  if there isn't '\r\n' there, continue.
- read serial buffer, append data there our local buffer
- check our local data buffer.  if there '!', have block.
- whatever block of data between '!' , '\r\n'
- remove block our local buffer, , go top


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Send and recieve data using serial connection (PC)


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums