1 /* Arduino terminal for PL2303 USB to serial converter and DealeXtreme GPRS modem. */
6 #include <cdcprolific.h>
8 // Satisfy the IDE, which needs to see the include statment in the ino too.
10 #include <spi4teensy3.h>
14 class PLAsyncOper : public CDCAsyncOper
17 uint8_t OnInit(ACM *pacm);
20 uint8_t PLAsyncOper::OnInit(ACM *pacm)
25 rcode = pacm->SetControlLineState(1);
29 ErrorMessage<uint8_t>(PSTR("SetControlLineState"), rcode);
34 //lc.dwDTERate = 9600;
35 lc.dwDTERate = 115200;
40 rcode = pacm->SetLineCoding(&lc);
43 ErrorMessage<uint8_t>(PSTR("SetLineCoding"), rcode);
49 PLAsyncOper AsyncOper;
50 PL2303 Pl(&Usb, &AsyncOper);
54 Serial.begin( 115200 );
55 #if !defined(__MIPSEL__)
56 while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
58 Serial.println("Start");
61 Serial.println("OSCOKIRQ failed to assert");
70 if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
74 /* reading the keyboard */
75 if(Serial.available()) {
76 uint8_t data= Serial.read();
78 /* sending to the phone */
79 rcode = Pl.SndData(1, &data);
81 ErrorMessage<uint8_t>(PSTR("SndData"), rcode);
82 }//if(Serial.available()...
84 /* reading the converter */
85 /* buffer size must be greater or equal to max.packet size */
86 /* it it set to 64 (largest possible max.packet size) here, can be tuned down
87 for particular endpoint */
90 rcode = Pl.RcvData(&rcvd, buf);
91 if (rcode && rcode != hrNAK)
92 ErrorMessage<uint8_t>(PSTR("Ret"), rcode);
94 if( rcvd ) { //more than zero bytes received
95 for(uint16_t i=0; i < rcvd; i++ ) {
96 Serial.print((char)buf[i]); //printing on the screen
99 }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING..