diff --git a/DMX-2.0/DriverBoitierV1.cs b/DMX-2.0/DriverBoitierV1.cs index 66e1a41..be64a37 100644 --- a/DMX-2.0/DriverBoitierV1.cs +++ b/DMX-2.0/DriverBoitierV1.cs @@ -103,7 +103,7 @@ namespace DMX2 void MainLoop() { - while(etat != etatAutomate.Fin) + while(!disposed && etat != etatAutomate.Fin) { switch (etat) { case etatAutomate.Deconnecte: diff --git a/DMX-2.0/DriverBoitierV2.cs b/DMX-2.0/DriverBoitierV2.cs index cce3096..67ad31c 100644 --- a/DMX-2.0/DriverBoitierV2.cs +++ b/DMX-2.0/DriverBoitierV2.cs @@ -209,7 +209,7 @@ namespace DMX2 void MainLoop () { //DateTime t = DateTime.Now; - while (etat != etatAutomate.Fin) { + while (!disposed && etat != etatAutomate.Fin) { try { switch (etat) { case etatAutomate.Deconnecte: diff --git a/DMX-2.0/DriverBoitierV3.cs b/DMX-2.0/DriverBoitierV3.cs index c4a9cb7..5741c47 100644 --- a/DMX-2.0/DriverBoitierV3.cs +++ b/DMX-2.0/DriverBoitierV3.cs @@ -42,7 +42,7 @@ namespace DMX2 Fin } - const int timeout = 200; + const int timeout = 100; // tampons Entrée/Sortie public byte[] inputbuffer = new byte[516]; @@ -130,15 +130,12 @@ namespace DMX2 Thread.Sleep (1500); return; } - serial = new SerialPort (portname);//, 9600, Parity.None, 8, StopBits.One); + serial = new SerialPort (portname); Console.WriteLine (portname); - //serial.DtrEnable = false; - //serial.ReadTimeout = 200; - //serial.WriteTimeout = 200; + try { serial.RtsEnable = true; serial.Open (); - //Attente(DateTime.Now.AddMilliseconds(100)); if(Synchronisation()) etat = etatAutomate.Transmission; @@ -169,11 +166,11 @@ namespace DMX2 return false; // Au cas ou le boitier attends une fin de commande : envoi 1030 octets a 0 (le boitier ignorera tout seul la suite) - byte[] tmpBuffer = new byte[530]; - //serial.Write (tmpBuffer, 0, 530); + byte[] tmpBuffer = new byte[2]; + serial.Write (tmpBuffer, 0, tmpBuffer.Length); // On attends un peu - Thread.Sleep (100); + Thread.Sleep (50); // Vide le buffer d'entree if (serial.BytesToRead > 0) @@ -204,7 +201,7 @@ namespace DMX2 void MainLoop () { //DateTime t = DateTime.Now; - while (etat != etatAutomate.Fin) { + while (!disposed && etat != etatAutomate.Fin) { try { switch (etat) { case etatAutomate.Deconnecte: diff --git a/DMX-2.0/DriverDMX.cs b/DMX-2.0/DriverDMX.cs index e862e3a..815a642 100644 --- a/DMX-2.0/DriverDMX.cs +++ b/DMX-2.0/DriverDMX.cs @@ -52,6 +52,8 @@ namespace DMX2 return DriverBoitierV1.Load(conduite, el); case "DriverBoitierV2": return DriverBoitierV2.Load(conduite,el); + case "DriverBoitierV3": + return DriverBoitierV3.Load(conduite,el); } return null; } diff --git a/arduino-hardware.patch b/dmx512_micro_ino/arduino-hardware.patch similarity index 100% rename from arduino-hardware.patch rename to dmx512_micro_ino/arduino-hardware.patch diff --git a/dmx512_micro_ino/dmx512_micro_ino.ino b/dmx512_micro_ino/dmx512_micro_ino.ino index ea808df..0c13a6d 100644 --- a/dmx512_micro_ino/dmx512_micro_ino.ino +++ b/dmx512_micro_ino/dmx512_micro_ino.ino @@ -18,10 +18,10 @@ volatile int index_input_pc=0; // entrée serial 0 volatile int index_output_pc=0; // sortie serial 0 volatile int index_input_dmx=513; // entrée dmx volatile int index_output_dmx=0; //sortie dmx -2 en attente de fin de transmission; -1 break; 0 à 512 transmission -volatile int index_output_dmx2=0; //sortie dmx -2 en attente de fin de transmission; -1 break; 0 à 512 transmission + volatile int etat_input_pc=0; // 0 raz ; 1 esc reçu ; 2 D reçu : pret à recevoir ; 3 prèt à emmetre volatile int start_code_rec=-1; -char key; // caractère reçu serial 0 + int ledPin = 13; // led interne int tx1pin = 1; // pin DMX serial 1 @@ -33,6 +33,7 @@ volatile int emissionPc=0; /* ------------ Gestion Liaison USB -------------- */ +/* On a surcharge tout ca pour optimiser les temps de transfert */ typedef struct { @@ -89,7 +90,7 @@ bool CDC_Setup(Setup& setup) return false; } -// lancé par interruption USB sur reception d'un char +// lancé par interruption USB sur reception d'un char <- Cette fonction nécessite une modif de la lib arduino void CDC_accept() { int c = USB_Recv(CDC_RX); @@ -175,12 +176,12 @@ void litUSB(char c) case 11: // 2nd parametre : duree du break en us etat_input_pc++; - //brk_timer_end = 255 - (c/2) +1; + brk_timer_end = (c/2); break; case 12: // 3eme parametre : duree du mab en us etat_input_pc++; - //mab_timer_end = 255 - (c/2) +1; + mab_timer_end = (c/2); break; case 13: // 4eme parametre : merge @@ -259,7 +260,6 @@ ISR(TIMER4_COMPA_vect) { digitalWrite(tx1pin, HIGH); // on met la broche 18 à 1 pendant 10 µs index_output_dmx=-3; - index_output_dmx2=-3; OCR4A = mab_timer_end ; TCNT4 = 0 ;// RAZ compteur timer TIFR4 = 0 ; //Clear Flags timer @@ -283,7 +283,6 @@ void setup() { // init pin led interne en sortie pinMode(ledPin, OUTPUT); - // initialisation à 250k de serial 1 // baudrate @@ -302,15 +301,11 @@ void setup() { sbi(UCSR1B, RXCIE1); //Interruption sur reception sbi(UCSR1B, TXCIE1); //Interruption pour fin de transmission - - - // init timer break TIMSK4 = 0; TCCR4C = 0; TCCR4B = 0; TCCR4A = 0; // 00000000 -// ASSR &= ~(1< 2µs } // fin du break - // suite du code + // octets d'état. Pour le moment, tous à 0 tab_input_dmx[513]= 0; tab_input_dmx[514]= 0; tab_input_dmx[515]=0; tab_input_dmx[516]=0; - if(_usbLineInfo.lineState) { // Si port ouvert + if(_usbLineInfo.lineState) { // Si port serie USB ouvert if(emissionPc!=0) { ecritUSB(); }