CDC.print

From Pinguino-Wiki
Jump to: navigation, search

Contents

Name

CDC.print - send string or numeral to CDC device

Description

This command sends a character or string to the CDC device - usually a text terminal.

The Communication Device Class (CDC) is a general-purpose way to enable all types of communications on the Universal Serial Bus (USB). This class makes it possible to connect communication devices such as digital telephones or analog modems, as well as networking devices like Asymmetric Digital Subscriber Line (ADSL, DSL) or Cable modems. While a CDC device enables the implementation of quite complex devices, it can also be used as a very simple method for communication on the USB. For example, a CDC device can appear as a virtual COM port (terminal window), which greatly simplifies application development on the host side.

checked 8bit PIC
  • X.4 rev.685 (+ modified patch) / Board 26j50 / Bootloader v4.2
  • X.4 rev.909 / Board 47j53 (A) / Bootloader v4.12

Syntax

 CDC.print(numeral_type , kind_type);

numeral_type: (u16)

 literal, variable

kind_type:

 FLOAT, DEC, HEX, BYTE, OCT, BIN

Example 1

u16 num;
float fv;
void setup()
{
    fv = 4.3;
    num = 200;
}
 
void loop()
{
// Send numeral through emulated serial port to pc
    CDC.printf( "\n\r ---- Output ---- "); 
    //CDC.printf( "\n\r Float--- " ); CDC.print( fv  , FLOAT ); 
    CDC.printf( "\n\r Dec  --- " ); CDC.print( num, DEC   );   
    CDC.printf( "\n\r HEX  --- " ); CDC.print( num, HEX   );   
    CDC.printf( "\n\r BYTE --- " ); CDC.print( num, BYTE  );  
    CDC.printf( "\n\r OCT  --- " ); CDC.print( num, OCT   );   
    CDC.printf( "\n\r BIN  --- " ); CDC.print( num, BIN   );   
    delay(2000);
    num++;
}

Bugs

Windows

On windows, the CONTROL_LINE variable must be used.

Instead of: CDC.print(num,DEC);

use: if (CONTROL_LINE) CDC.print(num,DEC);

CONTROL_LINE is used to know if a terminal is connected to Pinguino. If it is not used ( only on windows ) the USB buffer on the PC side can be overloaded.

OS X 10.6, 10.7, 10.8

The CDC device nodes /dev/cu.usbmodemXXXXX and /dev/tty.usbmodemXXXXX are created, but no i/o is possible (X.4 rev 909).

FreeBSD 8.1

The CDC device nodes /dev/ttyU0 and /dev/cuaU0 are created, but no i/o is possible (X.4 rev 909).

See also

Serial.printf

CDC.read

Comments

FLOAT type can not be compiled on 8bit PIC.
CDC.print( "some string" ) is not supported.

send String

Description Since Beta 9.5

Since Beta 9.5

Syntax

 CDC.print(String,Length);

Example

void setup()
{
}
 
void loop()
{
CDC.print("TOTO",4); // Send string throug emulated serial port to pc
delay(200);
}

Bugs

On windows, the CONTROL_LINE variable must be used.
Instead of: CDC.print("toto",4);
use: if (CONTROL_LINE) CDC.print("toto",4);

CONTROL_LINE is used to detect if a terminal is connected to Pinguino. If it is not used ( only on windows ) the USB buffer on the PC side can be overloaded.

See also

Printf for all supported formats.
Sprintf

CDC.getString        CDC.print        CDC.printf
CDC.println          CDC.read         CDC.write
CDC.getKey

Serial.getString     Serial.print     Serial.printf
Serial.println       Serial.read      Serial.write

lcd.print

Comments

Personal tools