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

Hi Fernando,

This'll be slow, so, just to be sure I understand, your example requires a physical 'loopback' wiring on a physical serial port in order to echo typed characters, right?

So, if I am just trying to send through USB, without any loopback in place, it should work just fine to send through USB, without echo, since the echo is only from the physical connection (which in my case is nonexistant), right?

include serial.ew  
include get.e  
include misc.e  
  
object val  
integer port, a  
atom hCom1  
  
constant MAXDWORD=#FFFFFFFF  
constant ESC=27  
  
port = 5				-- ADJUST TO YOUR PORT  
   
hCom1 = serial_open(port)  
if hCom1 < 0 then  
	printf(1,"Error opening port %d.\n\n",port)  
	abort(1)  
end if  
-- http://msdn.microsoft.com/en-us/library/aa363190%28v=VS.85%29.aspx  
-- A value of MAXDWORD, combined with zero values for both the ReadTotalTimeoutConstant 
-- and ReadTotalTimeoutMultiplier members,  
-- specifies that the read operation is to return immediately with the bytes  
--   that have already been received, even if no bytes have been received.  
SetCommTimeouts(hCom1,{MAXDWORD,0,0,0,0})  
SetCommState(hCom1, "baud:9600;parity:none;bits:8;stop:1;control:none")  
  
puts(1,"1) Connect TX and RX (loopback) (pins 2 and 3 in the DB9 connector).\n" &  
       "2) Every key you hit will be send and received by serial port and echoed to the screen.\n" &  
       "3) ESC abort.\n")  
PurgeComm(hCom1,PURGE_RXCLEAR)  
while 1 do  
	a = get_key()  
	if a != -1 then  
		if a = ESC then  
			puts(1,"\nAborted!\n")  
			abort(0)  
		end if  
		serial_puts(hCom1, a)				-- SEND KEY CODE TO SERIAL PORT  
	end if  
	val = serial_getc(hCom1)  
	if val != -1 then  
		puts(1,val)  
	end if  
end while  
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu