Re: [Eu 3.1]How to send many files to Arduino via USB?

new topic     » goto parent     » topic index » view thread      » older message » newer message
DanM_anew said...

Oh, ok, there ARE code characters defining the starts of the different fields in the block sent, good to know! I'll study your code, I'm going in the other direction, sending from an Eu coded 'terminal' pgm, received on Uno with C or C plus plus subset or something like that, but the general idea has to be about the same in order that the handshaking work, so I'll try to transpose that into the Uno code! smile .

Here's what I'm doing here in Eu terminal just after a send of a block to the Uno, I can't really tell if it's doing what I want, it's supposed to be waiting for a response FROM the Uno, indicating eventually if it's ok to send another block (or resend same one again):

     while 1 do 
--     puts(1, "this is in the while to receive echo" & "\n") 
 
--read count bytes from serial port 
--global function serial_get_bytes(atom hCom, integer count) 
 
            val = {} 
     		val = serial_getc(hCom1)  -- AND THIS RECEIVES AND DISPLAYS ANY RESPONSE 
	        if val != -1 then 
	          val &= serial_get_bytes(hCom1,length(chunk)) -- SHOULD get whole echo 
              puts(1, "\nIT GOT AN ECHO!  " & val & "\n") 
              puts(1, "length of echo= " & sprint(length(val)) & "\n\n") 
	          exit 
            end if 
     end while 

Does it seem like it's trying to do what I want? All I'm wanting it to do is wait to receive the handshake from the Uno, one or two responses, "all ok, send more", or "resend last block" eventually, but I'm not sure I'm doing it right in this initial version.

It's good to use the same packet format both directions, whether sending large data or something as small as an acknowledgment message. If you use the first byte of the message to identify the message type, you can create a list of message type constants and handle the incoming packets easily with switch/case or if/then statements, and even handle errors and retries easily.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu