Hello
I need your help as soon as possible.
I have a Arduino Mega board and a USB host shield (like this : http://www.ebay.es/itm/like/261880660401?limghlpsr=true&hlpht=true&ul_noapp=true&hlpv=2&chn=ps&lpid=115&ops=true&viphx=1).
I need send some information from PC using Serial communication to Arduino mega by its programing port, and send this information by the USB host shield using Serial communication too.
It must run like a bridge, I send information from pc this information passes through the board and it is sent through the USB host shield.
It seems easy, but I couldn't find someone who tell me how I could do it.
I need some example code or something. It is very important because I need do it for a work.
Sorry for my English.Thanks in advanced
I think that you don't understand the situation well because my english is not good enough .
I need to send information from pc using serial communication to my Arduino Mega 2560 ( I do that using its programing port ) , this information in only some conditions must be send to other machine. In this case an 3D printer. But I can't change the programming of this printer, this thing is imperative for me, it must be a closed system, I just can send the information that I want to the printer by its USB port.
As the Arduino Mega don't have a female USB port, I bought an USB host shield, maybe it is not the best way, but I asked a lot and everyone told me that this was the solution.
I now I need to solve that.
Your machine connects directly to your PC. Ask on the RepRap forums for more info, but as far as we can see there is nothing for the Arduino to do. Every thing you need to do can be done on the PC.
this information in only some conditions must be send to other machine.
That is the bit that is confusing us. We don't understand in what circumstances that would happen and what information needs to be withheld. Also that decision can be made at the PC.
However most host shields come with sample examples and one of them will be a serial communications example.
Exactly what shield do you have?
Have you run the serial example?
What is it that you do not understand, is it the shield or is it just programming itself?
The conditions are already programed. I have and "if-else" condition.
In the "if" part, the program control other things. But in the part "else" I need that the information is sent to the 3D printer.
I use this USB host shield (http://www.ebay.es/itm/like/261880660401?limghlpsr=true&hlpht=true&ul_noapp=true&hlpv=2&chn=ps&lpid=115&ops=true&viphx=1).
My problem is that I don't know how specify, when I send the information by Serial, that I want to sent this information by the USB host shield not by the programing port back to the PC.
The conditions are already programed. I have and "if-else" condition.
In the "if" part, the program control other things. But in the part "else" I need that the information is sent to the 3D printer.
Let's hope you know what you are doing because I haven't got a clue.
To send data look at the term_test example code. specifically the end bit where data is sent out from the USB port:-
/* sending back what was received */
rcode = adk.SndData( strlen( recv ), (uint8_t *)recv );
rcode = adk.SndData( strlen(( char * )msg ), msg );