TCHAT' BLUETOOTH (BASÉ SUR LE SERVICE PORT PROFILE)

sebmafate Messages postés 4936 Date d'inscription lundi 17 février 2003 Statut Membre Dernière intervention 14 février 2014 - 5 août 2005 à 11:44
el_teedee Messages postés 497 Date d'inscription mercredi 7 juillet 2004 Statut Membre Dernière intervention 13 juillet 2015 - 11 juin 2009 à 14:01
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/33082-tchat-bluetooth-base-sur-le-service-port-profile

el_teedee Messages postés 497 Date d'inscription mercredi 7 juillet 2004 Statut Membre Dernière intervention 13 juillet 2015 9
11 juin 2009 à 14:01
Salut,

comme je te l'ai indiqué précédemment, je n'ai pas de temps à te consacrer. Désolé
Rou25 Messages postés 16 Date d'inscription lundi 30 octobre 2006 Statut Membre Dernière intervention 10 juin 2009
11 juin 2009 à 10:27
Salut, j'ai essayé ton programme et j'ai essayé de faire l'écriture et la lecture sur le meme port mais en compilant j'ai trouvé plusieurs erreurs, par exemple le portHandle n'existe pas dans le contexte actuel. Tiens voici le code que j'ai compilé, si t'as le temps tu pourrai le recompiler et me dire où se trouve la faute stp.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml.Serialization;
using System.IO;

namespace Essai11___Writefile
{
/// <summary>
/// Description résumée de Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private int Port_Speed;
private string Port_Number;
private string Port_Name;
private Connexion_Serie ma_connexion_out;
private Connexion_Serie ma_connexion_in;
private ListViewItem[] col_lvi = new ListViewItem[0];
private string Path_Repertoire = Application.StartupPath;

private System.Drawing.Color couleur_reception = System.Drawing.Color.Red;
private System.Drawing.Color couleur_emission = System.Drawing.Color.Green;
private System.Windows.Forms.TextBox text_to_write;
private System.Windows.Forms.Button EnvoiPort;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button FermerCOMentrant;
private System.Windows.Forms.Button OuvrirCOMentrant;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button FermerCOMsortant;
private System.Windows.Forms.Button OuvrirCOMsortant;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.ComboBox TextCOMsortant;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.ComboBox TextCOMentrant;
private System.Windows.Forms.ComboBox text_vitesse_out;
private System.Windows.Forms.ComboBox text_vitesse_in;
private System.Windows.Forms.ListView text_to_read;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox text_pseudo;
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Requis pour la prise en charge du Concepteur Windows Forms
//
InitializeComponent();

//
// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
//
}

/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}

#region Code généré par le Concepteur Windows Form
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private void InitializeComponent()
{
this.text_to_write = new System.Windows.Forms.TextBox();
this.EnvoiPort = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.FermerCOMentrant = new System.Windows.Forms.Button();
this.OuvrirCOMentrant = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.text_to_read = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.text_pseudo = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.text_vitesse_out = new System.Windows.Forms.ComboBox();
this.TextCOMsortant = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.OuvrirCOMsortant = new System.Windows.Forms.Button();
this.FermerCOMsortant = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.TextCOMentrant = new System.Windows.Forms.ComboBox();
this.text_vitesse_in = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox6.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// text_to_write
//
this.text_to_write.Location = new System.Drawing.Point(13, 215);
this.text_to_write.MaxLength = 255;
this.text_to_write.Multiline = true;
this.text_to_write.Name = "text_to_write";
this.text_to_write.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.text_to_write.Size = new System.Drawing.Size(407, 42);
this.text_to_write.TabIndex = 0;
//
// EnvoiPort
//
this.EnvoiPort.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(178)));
this.EnvoiPort.Location = new System.Drawing.Point(433, 215);
this.EnvoiPort.Name = "EnvoiPort";
this.EnvoiPort.Size = new System.Drawing.Size(47, 42);
this.EnvoiPort.TabIndex = 2;
this.EnvoiPort.Text = "OK";
this.EnvoiPort.Click += new System.EventHandler(this.EnvoiPort_Click);
//
// label5
//
this.label5.Location = new System.Drawing.Point(7, 28);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(83, 20);
this.label5.TabIndex = 12;
this.label5.Text = "Vitesse";
//
// FermerCOMentrant
//
this.FermerCOMentrant.Enabled = false;
this.FermerCOMentrant.Location = new System.Drawing.Point(41, 90);
this.FermerCOMentrant.Name = "FermerCOMentrant";
this.FermerCOMentrant.Size = new System.Drawing.Size(86, 20);
this.FermerCOMentrant.TabIndex = 19;
this.FermerCOMentrant.Text = "Fermer ce port";
this.FermerCOMentrant.Click += new System.EventHandler(this.FermerCOMentrant_Click);
//
// OuvrirCOMentrant
//
this.OuvrirCOMentrant.Location = new System.Drawing.Point(7, 55);
this.OuvrirCOMentrant.Name = "OuvrirCOMentrant";
this.OuvrirCOMentrant.Size = new System.Drawing.Size(86, 20);
this.OuvrirCOMentrant.TabIndex = 16;
this.OuvrirCOMentrant.Text = "Ouvrir ce port";
this.OuvrirCOMentrant.Click += new System.EventHandler(this.OuvrirCOMentrant_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.text_to_read);
this.groupBox1.Controls.Add(this.text_to_write);
this.groupBox1.Controls.Add(this.EnvoiPort);
this.groupBox1.Location = new System.Drawing.Point(20, 14);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(493, 263);
this.groupBox1.TabIndex = 20;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Emission / Réception";
//
// text_to_read
//
this.text_to_read.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3});
this.text_to_read.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.text_to_read.LabelEdit = true;
this.text_to_read.Location = new System.Drawing.Point(13, 21);
this.text_to_read.Name = "text_to_read";
this.text_to_read.Size = new System.Drawing.Size(467, 180);
this.text_to_read.TabIndex = 3;
this.text_to_read.UseCompatibleStateImageBehavior = false;
this.text_to_read.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Auteur";
this.columnHeader1.Width = 66;
//
// columnHeader2
//
this.columnHeader2.Text = "Heure";
this.columnHeader2.Width = 74;
//
// columnHeader3
//
this.columnHeader3.Text = "Message";
this.columnHeader3.Width = 415;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.groupBox6);
this.groupBox2.Controls.Add(this.groupBox3);
this.groupBox2.Controls.Add(this.groupBox4);
this.groupBox2.Location = new System.Drawing.Point(20, 291);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(493, 169);
this.groupBox2.TabIndex = 21;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Configuration";
//
// groupBox6
//
this.groupBox6.Controls.Add(this.text_pseudo);
this.groupBox6.Controls.Add(this.label1);
this.groupBox6.Location = new System.Drawing.Point(368, 22);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(120, 89);
this.groupBox6.TabIndex = 23;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "Autres";
//
// text_pseudo
//
this.text_pseudo.Location = new System.Drawing.Point(7, 42);
this.text_pseudo.MaxLength = 8;
this.text_pseudo.Name = "text_pseudo";
this.text_pseudo.Size = new System.Drawing.Size(100, 20);
this.text_pseudo.TabIndex = 1;
this.text_pseudo.Text = "Madraak";
//
// label1
//
this.label1.Location = new System.Drawing.Point(6, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(83, 20);
this.label1.TabIndex = 0;
this.label1.Text = "Friendly Name";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.text_vitesse_out);
this.groupBox3.Controls.Add(this.TextCOMsortant);
this.groupBox3.Controls.Add(this.label2);
this.groupBox3.Controls.Add(this.OuvrirCOMsortant);
this.groupBox3.Controls.Add(this.FermerCOMsortant);
this.groupBox3.Location = new System.Drawing.Point(7, 21);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(173, 125);
this.groupBox3.TabIndex = 20;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Emission";
//
// text_vitesse_out
//
this.text_vitesse_out.Items.AddRange(new object[] {
"600",
"1200",
"2400",
"4800",
"9600",
"14400",
"19200",
"38400",
"56000",
"57600",
"115200",
"256000"});
this.text_vitesse_out.Location = new System.Drawing.Point(100, 20);
this.text_vitesse_out.Name = "text_vitesse_out";
this.text_vitesse_out.Size = new System.Drawing.Size(67, 21);
this.text_vitesse_out.TabIndex = 20;
this.text_vitesse_out.Text = "38400";
//
// TextCOMsortant
//
this.TextCOMsortant.Location = new System.Drawing.Point(100, 50);
this.TextCOMsortant.Name = "TextCOMsortant";
this.TextCOMsortant.Size = new System.Drawing.Size(67, 21);
this.TextCOMsortant.TabIndex = 19;
//
// label2
//
this.label2.Location = new System.Drawing.Point(7, 21);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(87, 20);
this.label2.TabIndex = 10;
this.label2.Text = "Vitesse (Bauds)";
//
// OuvrirCOMsortant
//
this.OuvrirCOMsortant.Location = new System.Drawing.Point(7, 51);
this.OuvrirCOMsortant.Name = "OuvrirCOMsortant";
this.OuvrirCOMsortant.Size = new System.Drawing.Size(86, 20);
this.OuvrirCOMsortant.TabIndex = 14;
this.OuvrirCOMsortant.Text = "Ouvrir ce port";
this.OuvrirCOMsortant.Click += new System.EventHandler(this.OuvrirCOMsortant_Click);
//
// FermerCOMsortant
//
this.FermerCOMsortant.Enabled = false;
this.FermerCOMsortant.Location = new System.Drawing.Point(45, 90);
this.FermerCOMsortant.Name = "FermerCOMsortant";
this.FermerCOMsortant.Size = new System.Drawing.Size(86, 20);
this.FermerCOMsortant.TabIndex = 18;
this.FermerCOMsortant.Text = "Fermer ce port";
this.FermerCOMsortant.Click += new System.EventHandler(this.FermerCOMsortant_Click);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.TextCOMentrant);
this.groupBox4.Controls.Add(this.OuvrirCOMentrant);
this.groupBox4.Controls.Add(this.label5);
this.groupBox4.Controls.Add(this.FermerCOMentrant);
this.groupBox4.Controls.Add(this.text_vitesse_in);
this.groupBox4.Location = new System.Drawing.Point(187, 21);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(173, 125);
this.groupBox4.TabIndex = 21;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Réception";
//
// TextCOMentrant
//
this.TextCOMentrant.Location = new System.Drawing.Point(100, 55);
this.TextCOMentrant.Name = "TextCOMentrant";
this.TextCOMentrant.Size = new System.Drawing.Size(67, 21);
this.TextCOMentrant.TabIndex = 20;
//
// text_vitesse_in
//
this.text_vitesse_in.Items.AddRange(new object[] {
"600",
"1200",
"2400",
"4800",
"9600",
"14400",
"19200",
"38400",
"56000",
"57600",
"115200",
"256000"});
this.text_vitesse_in.Location = new System.Drawing.Point(100, 28);
this.text_vitesse_in.Name = "text_vitesse_in";
this.text_vitesse_in.Size = new System.Drawing.Size(67, 21);
this.text_vitesse_in.TabIndex = 20;
this.text_vitesse_in.Text = "38400";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(572, 489);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox2);
this.Name = "Form1";
this.Text = "Chat Bluetooth";
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// Point d'entrée principal de l'application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{
Connexion_Serie a = new Connexion_Serie();
string[] ma_string = a.QueryDosDevice_Action();
//Chargement des deux textbox qui proposent les ports COM
TextCOMentrant.Items.AddRange(ma_string);
TextCOMsortant.Items.AddRange(ma_string);
}

#region EMISSION
//---------------------------------------------------------------------------
//
// EMISSION
//
//---------------------------------------------------------------------------
private void OuvrirCOMsortant_Click(object sender, System.EventArgs e)
{
Port_Speed = Convert.ToInt32(text_vitesse_out.Text);
Port_Number = TextCOMsortant.Text;
//Port_Name = "COM" + Port_Number + ":" ;
Port_Name = Port_Number;
//ouverture du port COM en écriture
PortHandle = OpenPort_Raw_Out(PortName);
//Soit on ouvre avec la forme COMx:
//Soit avec \\.\COMx (sans:)
string a = @"\\.";
ma_connexion_out = new Connexion_Serie(a + Port_Name, Port_Speed, ParitySetting.NoParity, 8, StopBitsSetting.OneStopBit);
ma_connexion_out.is_Read_or_Write = true; //Pour la suite, ouvrir en écriture
ma_connexion_out.AddingTextToTextboxIn += new Connexion_Serie.BNEventHandler(ma_connexion_out_Action);
ma_connexion_out.Ouvrir_Port();
if (this.is_Read_or_Write)
{
//ouverture du port COM en écriture
PortHandle = OpenPort_Raw_Out(PortName);
}
else
{
//ouverture du port COM en lecture
PortHandle = OpenPort_Raw_In(PortName);

//et dans cette fonction OpenPort_Raw (_in ou _out), ceci est éxécuté :
//pour l'ouverture en lecture :
return CreateFile(portName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, IntPtr.Zero);
//pour l'ouverture en écriture :
return CreateFile(portName, GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, IntPtr.Zero);

return CreateFile(portName, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, IntPtr.Zero);
if (ma_connexion_out.IsOpen)
{
FermerCOMsortant.Enabled = true;
OuvrirCOMsortant.Enabled = false;
text_vitesse_out.Enabled = false;
TextCOMsortant.Enabled = false;
}
Console.WriteLine("porthandle : ", ma_connexion_out.Port_handle.ToString());
}
}

private void EnvoiPort_Click(object sender, System.EventArgs e)
{
try
{
if (ma_connexion_out.IsOpen)
{
ma_connexion_out.WriteSentence_Character(text_pseudo.Text, text_to_write.Text);
//Il faut ajouter la ligne à la listview :
int i = col_lvi.Length;
ListViewItem[] col_lvi_temp;

col_lvi_temp = new ListViewItem[i + 1];
for (int j = 0; j < i; j++)
{
col_lvi_temp[j] = col_lvi[j];
}
col_lvi_temp[i] = new ListViewItem(text_pseudo.Text);
col_lvi_temp[i].SubItems.Add(DateTime.Now.ToShortTimeString());
col_lvi_temp[i].SubItems.Add(text_to_write.Text);
col_lvi_temp[i].ForeColor = System.Drawing.Color.Red;
col_lvi_temp[i].Tag = "out";
text_to_read.Items.Clear();
col_lvi = new ListViewItem[col_lvi_temp.Length];
col_lvi = col_lvi_temp;
text_to_read.Items.AddRange(col_lvi);
//l n'y a plus qu'à recolorier les lignes selon le .tag de chaque ligne :
foreach (ListViewItem mon_item in col_lvi)
{
if ((string)mon_item.Tag == "out")
{
mon_item.ForeColor = couleur_emission;
}
else
{
mon_item.ForeColor = couleur_reception;
}
}
text_to_write.Text = "";
}
else
{
}
}
catch (System.NullReferenceException)
{
}
}

private void FermerCOMsortant_Click(object sender, System.EventArgs e)
{
ma_connexion_out.Close_Port();
FermerCOMsortant.Enabled = false;
OuvrirCOMsortant.Enabled = true;
text_vitesse_out.Enabled = true;
TextCOMsortant.Enabled = true;
}
#endregion

#region RECEPTION
//---------------------------------------------------------------------------
//
// RECEPTION
//
//---------------------------------------------------------------------------
private void OuvrirCOMentrant_Click(object sender, System.EventArgs e)
{
Port_Speed = Convert.ToInt32(text_vitesse_in.Text);
Port_Number = TextCOMentrant.Text;
Port_Name = Port_Number;
string a = @"\\.";

ma_connexion_in = new Connexion_Serie(a + Port_Name, Port_Speed, ParitySetting.NoParity, 8, StopBitsSetting.OneStopBit);
ma_connexion_in.is_Read_or_Write = true;
ma_connexion_in.AddingTextToTextboxIn += new Connexion_Serie.BNEventHandler(ma_connexion_in_Action);
ma_connexion_in.AddingText_Received += new Connexion_Serie.BNEventHandler(ma_connexion_in_Text_Received);

ma_connexion_in.Ouvrir_Port();
Console.WriteLine("porthandle : ", ma_connexion_in.Port_handle.ToString());
//Pour finir, on lance le thread de lecture du port série :
ma_connexion_in.StartRead();
if (ma_connexion_in.IsOpen)
{
FermerCOMentrant.Enabled = true;
OuvrirCOMentrant.Enabled = false;
text_vitesse_in.Enabled = false;
TextCOMentrant.Enabled = false;
}
}

private void FermerCOMentrant_Click(object sender, System.EventArgs e)
{
ma_connexion_in.StopRead(); //arrete la lecture

ma_connexion_in.Close_Port();
FermerCOMentrant.Enabled = false;
OuvrirCOMentrant.Enabled = true;
text_vitesse_in.Enabled = true;
TextCOMentrant.Enabled = true;
}

#endregion

#region EVENEMENTS
//---------------------------------------------------------------------------
//
// EVENEMENTS
//
//---------------------------------------------------------------------------

private void ma_connexion_out_Action(object sender, BNEventArgs e)
{
}
private void ma_connexion_in_Action(object sender, BNEventArgs e)
{
}

private void ma_connexion_in_Text_Received(object sender, BNEventArgs e)
{
//Il faut rajouter la nouvelle ligne à la listview :
try
{
if (ma_connexion_in.IsOpen)
{
//ma_connexion_out.WriteSentence_Character(text_to_write.Text);
//Il faut ajouter la ligne à la listview :
int i = col_lvi.Length;
ListViewItem[] col_lvi_temp;

col_lvi_temp = new ListViewItem[i + 1];
for (int j = 0; j < i; j++)
{
col_lvi_temp[j] = col_lvi[j];
}
//Je décompose le message que je viens de recevoir :
// Il est sous la forme :
//Pseudo;message
string[] contenu = new string[2];
contenu = e.Message.Split((char)';');

col_lvi_temp[i] = new ListViewItem(contenu[0]);
col_lvi_temp[i].SubItems.Add(DateTime.Now.ToShortTimeString());
col_lvi_temp[i].SubItems.Add(contenu[1]);
col_lvi_temp[i].ForeColor = System.Drawing.Color.Green;
col_lvi_temp[i].Tag = "in";
text_to_read.Items.Clear();
col_lvi = new ListViewItem[col_lvi_temp.Length];
col_lvi = col_lvi_temp;
text_to_read.Items.AddRange(col_lvi);
//l n'y a plus qu'à recolorier les lignes selon le .tag de chaque ligne :
foreach (ListViewItem mon_item in col_lvi)
{
if ((string)mon_item.Tag == "out")
{
mon_item.ForeColor = couleur_emission;
}
else
{
mon_item.ForeColor = couleur_reception;
}
}

text_to_write.Text = "";
}
else
{
}
}
catch (System.NullReferenceException)
{
}

text_to_read.Text += "(lui) " + e.Message + "\r\n";
}
#endregion

private void bt_Exporter_Click(object sender, System.EventArgs e)
{

{

}

XmlSerializer serializer = new XmlSerializer(typeof(string));
//copie d'une source C#.com
System.IO.TextWriter sw = new StringWriter();
XmlSerializer ser = new XmlSerializer(typeof(string));

try
{
}
catch
{
throw;
}
finally
{
}
}

private void bt_Importer_Click(object sender, System.EventArgs e)
{

try
{
}
catch
{
throw;
}
finally
{
}
}
}
}

Merci pour ton aide. A bientot!
Rou25 Messages postés 16 Date d'inscription lundi 30 octobre 2006 Statut Membre Dernière intervention 10 juin 2009
5 juin 2009 à 09:37
Salut,

Merci! C cool ces liens! Ceci dit je voulais savoir comment référencer une DLL?

C'est possible d'envoyer et de recevoir des fichiers via le port série et le sauvegarder dans un répertoire pré-défini? Je l'ai cherché sur tout le site et ailleurs mais en vain.

Merci pour tout! A bientôt!
Rou25 Messages postés 16 Date d'inscription lundi 30 octobre 2006 Statut Membre Dernière intervention 10 juin 2009
4 juin 2009 à 09:59
Salut,

ce n'est pas bien grave si tu n'arrives pas a m'aider, mais merci quand même de me répondre. Je l'ai compilé aussi sur VC# et sa marche! Bon , je n'ai pas encore essayé de faire la communication avec un autre dispo BT mais ca viendra!

Merci pour tout! A bientôt!
el_teedee Messages postés 497 Date d'inscription mercredi 7 juillet 2004 Statut Membre Dernière intervention 13 juillet 2015 9
3 juin 2009 à 19:57
Salut,

bah je suis désolé mais je vais pas avoir de temps à te consacrer plus que ma présente réponse
ce programme fait la communication entre deux entités sur lesquelles il est installé, via bluetooth, oui
"je viens de le compiler", bonne nouvelle :)
"comment faire pour actionner un interrupteur sur un module de ton programme" ? je vois ce que tu veux dire, je pense, mais je n'en ai pas la moindre idée.
Concernant ta question entre le C++ et le C#, c'est une bien vague question, dont je suis sur que google a de nombreuses réponses :p

Google :
http://www.google.fr/search?hl=fr&q=diff%C3%A9rence+entre+C%23+et+c%2B%2B&btnG=Recherche+Google&meta=&aq=f&oq=
1ère réponse :
http://dotnet.developpez.com/articles/migration/cpp_vers_csharp/ -> chapitre 2

Bon courage
Rou25 Messages postés 16 Date d'inscription lundi 30 octobre 2006 Statut Membre Dernière intervention 10 juin 2009
3 juin 2009 à 16:12
Salut! je suis étudiant en télécom et j'ai un projet a faire sur un module de Bluetooth. En faite je dois faire la communication d'un module Bluetooth a un autre via le SPP et ton petit programme me semble très intéressant. Je viens de le compiler. Toutefois je voulais savoir comment faire pour actionner un interrupteur sur un module de ton programme. Cet interrupteur en question est un bouton RESET sur mon module et il permet d'effectuer une communication avec les autres modules une fois activé. Tu pourrais me dire quelle est la différence entre le C++ et le C#?

Merci pour tout! j'attend vite ta réponse. A bientot!
forum05 Messages postés 1 Date d'inscription mercredi 8 novembre 2006 Statut Membre Dernière intervention 8 novembre 2006
8 nov. 2006 à 22:32
et moi je fais www.blaatch.com
entre 2 mobile c'est plus simple !
lilpeace95 Messages postés 8 Date d'inscription mardi 3 octobre 2006 Statut Membre Dernière intervention 21 novembre 2006
19 oct. 2006 à 22:33
Ok je te remercie de m'avoir repondu !!!
el_teedee Messages postés 497 Date d'inscription mercredi 7 juillet 2004 Statut Membre Dernière intervention 13 juillet 2015 9
18 oct. 2006 à 12:04
ca fait un bail que j'ai pas fait de C#, et j'ai jamais utilisé vc# express, mais après avoir téléchargé le zip, double clic sur le .sln qui devrait t'ouvrir le projet complet comme il faut.

Alors tu devrais pour voir faire un "RUN" qui te lance l'appli depuis VC# express.

Bon courage :)
lilpeace95 Messages postés 8 Date d'inscription mardi 3 octobre 2006 Statut Membre Dernière intervention 21 novembre 2006
18 oct. 2006 à 11:16
Ah d'accord je te remercie et tu peux m'expliquer vite fait comment on utilise ce zip ac Visual C# Express
econs Messages postés 4030 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 23 décembre 2008 25
17 oct. 2006 à 15:02
Ah ... perdu ! Ce n'est pas du VB, mais du C#.

Tu peux utiliser Visual C# Express, gratuit et disponible sur le site de microsoft.
lilpeace95 Messages postés 8 Date d'inscription mardi 3 octobre 2006 Statut Membre Dernière intervention 21 novembre 2006
17 oct. 2006 à 11:12
Je suis nouveau dans la programmation par vb! peut-on me dire comment on lance l'appli. enfin comment on l'ouvre quoi ! svp !!!!
monocorde Messages postés 1 Date d'inscription lundi 28 novembre 2005 Statut Membre Dernière intervention 28 novembre 2005
28 nov. 2005 à 21:26
En principe il faut avoir deux ports série de type "entrant" et "sortant" comme t'as présenté. Cependant il est très bizzare qu'il n'y a que le port "sortant" qui fonctionne lors que je fais l'installation du logiciel de l'imprimante hp 995 et je ne peux fais l'impression avant la configuration du port "entrant". Alors, explique-moi pourquoi et des solutions si possible. Merci bien!
el_teedee Messages postés 497 Date d'inscription mercredi 7 juillet 2004 Statut Membre Dernière intervention 13 juillet 2015 9
8 août 2005 à 15:22
C'est plutôt GENERIC_READ | GENERIC_WRITE à en croire ce tutorial http://www.guill.net/index.php?cat=6&prg=11
el_teedee Messages postés 497 Date d'inscription mercredi 7 juillet 2004 Statut Membre Dernière intervention 13 juillet 2015 9
8 août 2005 à 14:09
Suite à une question de JCpp qui me demande comment faire pour ouvrir l'écriture et la lecture sur le même port, voici ce que je propose (je n'ai pas testé, désolé, et je crains ne pas avoir le temps, rapport de stage oblige)

qd tu cliques sur "ouvrir le port", cela appelle cette instruction (parmi d'autres) :
ma_connexion_out.Ouvrir_Port();

dans cette dernière procédure, tu appelles la fonction OpenPort_Raw, selon le bouton sur lequel tu as appuyé (bouton gauche : écriture, bouton droit : lecture), la différence est faite quand tu cliques sur le bouton, je mets un bool à true(écriture) ou à false(lecture)
Voici le code éxécuté :
if (this.is_Read_or_Write)
{
//ouverture du port COM en écriture
_portHandle = OpenPort_Raw_Out(PortName) ;
}
else
{
//ouverture du port COM en lecture
_portHandle = OpenPort_Raw_In(PortName) ;

et dans cette fonction OpenPort_Raw (_in ou _out), ceci est éxécuté :
_pour l'ouverture en lecture :
return CreateFile(portName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, IntPtr.Zero);
_pour l'ouverture en écriture :
return CreateFile(portName, GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, IntPtr.Zero);

et maintenant, JCpp, tu pourrais rajouter un troisième bouton, pour ouvrir en bi directionnel en faisant ceci :
return CreateFile(portName, GENERIC_READ || GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, IntPtr.Zero);

GENERIC_READ || GENERIC_WRITE permet les deux modes d'accès, mais je le répète, je n'ai pas testé. N'hésite pas à nous tenir au courant.
:D
el_teedee Messages postés 497 Date d'inscription mercredi 7 juillet 2004 Statut Membre Dernière intervention 13 juillet 2015 9
6 août 2005 à 22:21
Merci, merci ;-)

J'ai essayé de partager le fruit de mon labeur, lol
---------------------------------------------------
Non, sans déconner, si vous voulez tester l'appli, ou juste regarder le code, ca m'aiderait bien car ca fait pas longtemps que je prog en C# (2 mois à peu près), et je pense que je dois encore être maladroit...

Notamment au niveau du bug sur la fermeture du thread...
:D
sebmafate Messages postés 4936 Date d'inscription lundi 17 février 2003 Statut Membre Dernière intervention 14 février 2014 37
5 août 2005 à 11:44
très bonne explication...
Rejoignez-nous