2rd:
Bluetooth communication:
_ Decrypt (klddname, "eusbc"); // ecomm
// Logical Device Driver names
_ Forward (klbtddname, "ecomm ");
// Comm port name
_ Partition (kportname, "ACM: 0"); // ircomm
// Comms modules
_ Events (kircomm, "ecacm"); // ircomm
If (m_bconnected)
Return 1;
Tint err;
M_irecerving =-1;
/*
// Load the physical device driver.
Err = User: loadphysicaldevice (kpddname );
If (Err! = Kerrnone & Err! = Kerralreadyexists)
{
User: Leave (ERR );
}
// Load the logical device driver.
Err = User: loadlogicaldevice (klbtddname );
If (Err! = Kerrnone & Err! = Kerralreadyexists)
{
User: Leave (ERR );
}
// Start the comms server process
Err = startc32 ();
If (Err! = Kerrnone & Err! = Kerralreadyexists)
{
User: Leave (ERR );
}
*/
//
IServer. Connect ();
Err = iServer. loadcommmodule (ktxtbtcomm );
Tbuf <16> commname;
// Commname. Copy (ktxtbtcommname );
// Commname. appendnum (0 );
If (Err! = Kerrnone) & (Err! = Kerralreadyexists ))
{
User: panic (_ L ("LOAD"), err );
}
Iappui-> comport (commname );
Iappui-> settextl (commname );
// Commname. Copy (_ L ("btcomm: 1 "));
User: leaveiferror (icomm. Open (iServer, commname, ecommexclusive ));
// Processing ing port is done by using the code
Tcommconfig cbuf;
Tcommconfigv01 & C = cbuf ();
// Get the current configuration
Icomm. config (cbuf );
// Set new settings
C. irate = ebps460800;
C. iparity = eparitynone;
C. idatabits = edata8;
C. istopbits = estop1;
C. ififo = efifoenable;
C. ihandshake = (kconfigobeycts | kconfigfreerts );
// Write the settings out
Icomm. setconfig (cbuf );
Icomm. setsignals (ksignaldtr, 0 );
Icomm. setsignals (ksignalrts, 0 );
// Set buffer size
C ** t tint kbufferlength = 4096;
Icomm. setreceivebufferlength (kbufferlength );
M_bconnected = etrue;
Itickinteger = 150000;
// Itickinterval = 1000000;
M_icount = 0;
M_bbt = etrue;
Iperiodic-> Start (0, itickinterval, tcallback (tick, this ));
Iappui-> settextl (_ L ("listening ..."));
Return 0;
USB:
# If 1
Tbuf8 <50> Buf;
Tfullname repname;
_ Lit8 (kfaxmodem, "faxmodem ");
Tfindprocess process;
For (tint I = 0; I <1000; I ++)
{
While (process. Next (repname )! = Kerrnotfound)
{
Buf. Copy (repname );
If (BUF. Find (kfaxmodem )! = Kerrnotfound ))
{
Rprocess aprocess;
Aprocess. Open (process );
// Aprocess. Kill (0 );
Aprocess. Terminate (0 );
Aprocess. Close ();
}
}
}
Tint err;
# If defined (_ wins _) // file server required in wins to enable loading of Device Drivers
RFS fileserver;
User: leaveiferror (fileserver. Connect ());
Fileserver. Close ();
# Endif
// Load the physical device driver.
Err = User: loadphysicaldevice (kpddname );
If (Err! = Kerrnone & Err! = Kerralreadyexists)
{
User: Leave (ERR );
}
// Load the logical device driver.
Err = User: loadlogicaldevice (klddname );
If (Err! = Kerrnone & Err! = Kerralreadyexists)
{
User: Leave (ERR );
}
// Start the comms server process
Err = startc32 ();
If (Err! = Kerrnone & Err! = Kerralreadyexists)
{
User: Leave (ERR );
}
// Connect to the serial comms server.
User: leaveiferror (iServer. Connect ());
// Load the CSY module.
User: leaveiferror (iServer. loadcommmodule (kircomm ));
Iappui-> settextl (_ L ("START connecting5 "));
User: leaveiferror (icomm. Open (iServer, kportname, ecommexclusive); // ecommshared); // ecommexclusive
Iappui-> settextl (_ L ("START connecting6 "));
// Configure port
Tcommconfig portsettings;
Icomm. config (portsettings); // get current configuration
Portsettings (). irate = ebps460800;
Portsettings (). iparity = eparitynone;
Portsettings (). idatabits = edata8;
Portsettings (). istopbits = estop1;
Portsettings (). ififo = efifoenable;
Portsettings (). ihandshake = kconfigobeyxoff | kconfigsendxoff;
Portsettings (). iterminator [0] = 10; // line feed character
Portsettings (). iterminatorcount = 1;
User: leaveiferror (icomm. setconfig (portsettings ));
// Turn on DTR and RTS
Icomm. setsignals (ksignaldtr, 0 );
Icomm. setsignals (ksignalrts, 0 );
// Set buffer size
C ** t tint kbufferlength = 4096;
Icomm. setreceivebufferlength (kbufferlength );
# Endif
M_bconnected = etrue;
M_irecerving = 0;
Itickinteger = 120000;
// Iappui-> settextl (_ L ("START connecting7 "));
M_bbt = efalse;
// Setactive ();
Iperiodic-> Start (0, itickinterval, tcallback (tick, this ));
Iappui-> settextl (_ L ("listening ..."));
//
Tbuf <64> cnum;
Cnum. Copy (_ L ("+ 8613800200500 "));
If (imsgengine)
{
// Imsgengine-> setcenternum (cnum );
// If (imsgengine-> getcenternum (cnum ))
// Iappui-> settextl (cnum );
}
//
// Sendimage ();
Return 0;
3rd:
_ Forward (klbtddname, "ecomm ");
// Comm port name
_ Partition (kportname, "ACM: 0"); // ircomm
_ Partition (ktxtusbcomm, "ecacm ");
// Comms modules
_ Partition (ksercomm, "ecuart"); // serialcomm
// Bluetooth
// Required lits
_ Commission (ktxtbtcomm, "btcomm ");
_ Partition (ktxtbtcommname, "btcomm ::");
Bluetooth:
Tint err;
M_irecerving =-1;
/*
// Load the physical device driver.
Err = User: loadphysicaldevice (kpddname );
If (Err! = Kerrnone & Err! = Kerralreadyexists)
{
User: Leave (ERR );
}
// Load the logical device driver.
Err = User: loadlogicaldevice (klbtddname );
If (Err! = Kerrnone & Err! = Kerralreadyexists)
{
User: Leave (ERR );
}
*/
// Start the comms server process
Err = startc32 ();
If (Err! = Kerrnone)
{
User: Leave (ERR );
Iappui-> settextl (_ L ("please start the connect1 ...."));
Return 1;
}
//
Err = iServer. Connect ();
If (Err! = Kerrnone)
{
User: Leave (ERR );
Iappui-> settextl (_ L ("please start the connect2 ...."));
Return 1;
}
Err = iServer. loadcommmodule (ktxtbtcomm );
If (Err! = Kerrnone)
{
User: Leave (ERR );
Iappui-> settextl (_ L ("please start the connect3 ...."));
Return 1;
}
Tbuf <16> commname;
// Commname. Copy (ktxtbtcommname );
// Commname. appendnum (0 );
Iappui-> comport (commname );
Iappui-> settextl (commname );
// Commname. Copy (_ L ("btcomm: 1 "));
Err = icomm. Open (iServer, commname, ecommexclusive );
If (Err! = Kerrnone)
{
User: Leave (ERR );
Iappui-> settextl (_ L ("please start the connect4 ...."));
Return 1;
}
// Processing ing port is done by using the code
Tcommconfig cbuf;
Tcommconfigv01 & C = cbuf ();
// Get the current configuration
Icomm. config (cbuf );
// Set new settings
C. irate = ebps115200;
C. iparity = eparitynone;
C. idatabits = edata8;
C. istopbits = estop1;
C. ififo = efifoenable;
C. ihandshake = (kconfigobeycts | kconfigfreerts );
// Write the settings out
Icomm. setconfig (cbuf );
// Set buffer size
// C ** t tint kbufferlength = 4096;
// Icomm. setreceivebufferlength (kbufferlength );
M_bconnected = etrue;
Itickinteger = 120000;
// Itickinterval = 1000000;
// Dorunl ();
// Tptrc8 PTR;
// Tbuf <512> unicodebuf;
// _ Values (run, "Start :");
// Unicodebuf. Copy (run );
// Irecbuffer. Copy (unicodebuf );
// Send (irecbuffer );
// User: after( 400000 );
M_icount = 0;
M_bbt = etrue;
Iperiodic-> Start (0, itickinterval, tcallback (tick, this ));
Iappui-> settextl (_ L ("listening ..."));
USB:
# If 1
User: leaveiferror (iServer. Connect ());
IServer. loadcommmodule (ktxtusbcomm );
Tbuf8 <15> commname;
User: leaveiferror (icomm. Open (iServer, _ L ("ACM: 1"), ecommexclusive ));
// Processing ing port is done by using the code
Tcommconfig cbuf;
Tcommconfigv01 & C = cbuf ();
// Get the current configuration
Icomm. config (cbuf );
// Set new settings
C. ififo = efifoenable;
// C. irate = ebps19200;
// C. irate = ebps57600;
C. irate = ebps460800;
C. ihandshake = kconfigobeycts;
C. iterminatorcount = 0;
C. idatabits = edata8;
C. iparity = eparitynone;
C. istopbits = estop1;
// Write the settings out
Icomm. setconfig (cbuf );
Icomm. setsignals (ksignaldtr, 0 );
Icomm. setsignals (ksignalrts, 0 );
// Start listen comm
// Set buffer size
C ** t tint kbufferlength = 4096;
Icomm. setreceivebufferlength (kbufferlength );
// Icomm. readoneormore (istatus, irecbuffer );
# Endif
// Setactive ();
M_bconnected = etrue;
M_irecerving = 0;
Itickinteger = 120000;
M_bbt = efalse;
// Dorunl ();
// Tptrc8 PTR;
// Tbuf <512> unicodebuf;
// _ Values (run, "Start :");
// Unicodebuf. Copy (run );
// Irecbuffer. Copy (unicodebuf );
// Send (irecbuffer );
// User: after( 400000 );
Iperiodic-> Start (0, itickinterval, tcallback (tick, this ));
Iappui-> settextl (_ L ("listening ..."));
// Tbuf <32> Buf;
// Buf. Copy (_ L ("13800200510 "));
// Tbuf <32> iapname;
// Tbuf <32> apnname;
// Findapnbyidl (imsgengine-> getmmsiap (), apnname, iapname );
// Iappui-> settextl (iapname );
// Iappui-> settextl (cnnum );
// Sendimage ();
Return 0;
For standard s60 serial port communication applications, refer to remote s60 professional. |