Serial port: To which kind of variable can I assing this SERIAL_8N1?(Solved)

It's one of the parameter to set the serial port:

Serial.begin(speed, config)

speed: in bits per second (baud) - long
config: sets data, parity, and stop bits. Valid values are :

SERIAL_5N1
SERIAL_6N1
SERIAL_7N1
SERIAL_8N1 (the default)
SERIAL_5N2
SERIAL_6N2
SERIAL_7N2
SERIAL_8N2
SERIAL_5E1
SERIAL_6E1
SERIAL_7E1
SERIAL_8E1
SERIAL_5E2
SERIAL_6E2
SERIAL_7E2
SERIAL_8E2
SERIAL_5O1
SERIAL_6O1
SERIAL_7O1
SERIAL_8O1
SERIAL_5O2
SERIAL_6O2
SERIAL_7O2
SERIAL_8O2

I figure out it's not a String, but I can't find what it is. Any one know?

Just a single byte value:

#define SERIAL_5N1 0x00
#define SERIAL_6N1 0x02
#define SERIAL_7N1 0x04
#define SERIAL_8N1 0x06
#define SERIAL_5N2 0x08
#define SERIAL_6N2 0x0A
#define SERIAL_7N2 0x0C
#define SERIAL_8N2 0x0E
#define SERIAL_5E1 0x20
#define SERIAL_6E1 0x22
#define SERIAL_7E1 0x24
#define SERIAL_8E1 0x26
#define SERIAL_5E2 0x28
#define SERIAL_6E2 0x2A
#define SERIAL_7E2 0x2C
#define SERIAL_8E2 0x2E
#define SERIAL_5O1 0x30
#define SERIAL_6O1 0x32
#define SERIAL_7O1 0x34
#define SERIAL_8O1 0x36
#define SERIAL_5O2 0x38
#define SERIAL_6O2 0x3A
#define SERIAL_7O2 0x3C
#define SERIAL_8O2 0x3E

Wow, cool thank's it will be even eazer then i touth.

Frédéric_Plante:
Wow, cool thank's it will be even eazer then i touth.

No worries.

but I can't find what it is

For your reference I added a link to the containing file on github.
But you can view the entire core API here ( or your local installation ):https://github.com/arduino/Arduino/blob/ide-1.5.x/hardware/arduino/avr/cores/arduino/

Got any idea how to cut this to smaller? Ill go think about it in my nightmare... lol

	if (bit_parite == 0){

		if(longueur_donnees == 7){

			if (bit_arret == 0){}
			else if (bit_arret == 2){}

		}

		if(longueur_donnees == 8){

			if (bit_arret == 0){}
			else if (bit_arret == 2){}
		}

	}

	else if (bit_parite = 1){

		if(longueur_donnees == 7){
		
			if (bit_arret == 0){}
			else if (bit_arret == 2){}

		}

		if(longueur_donnees == 8){

			if (bit_arret == 0){}
			else if (bit_arret == 2){}

		}

	}

	else if (bit_parite = 2){

		if(longueur_donnees == 7){

			if (bit_arret == 0){}
			else if (bit_arret == 2){}

		}

		if(longueur_donnees == 8){

			if (bit_arret == 0){}
			else if (bit_arret == 2){}

		}

	}

What goes inside the curly brackets, a simple assignment / function call / something complex?

byte is an Arduino specific, include Arduino.h in your lib.

Now, I'm not sure how good this is going to be for your nightmares, however here is a one liner.
I'll check it through again, but it looks ok.

configuration_UART = ( ( ( bit_parite * 4 ) + ( longueur_donnees == 7 ? 0 : 2 ) + ( bit_arret ? 1 : 0 ) )[ "emgo\x95\x9D\x97\x9F\x85\x8D\x87\x8F" ] ) - 'a';

Questions? :slight_smile:

Wow! It was about time I talk about this problem. Thank you so much. I should of though about it, I included this to my *.cpp but not to my *.h. Now byte work. Yeap thank you superfully

#if (ARDUINO >= 100)

	#include "Arduino.h"
	
#else
 
	#include "WProgram.h"
	
#endif

I will cross 2 serial port tomorow to try this:

configuration_UART = ( ( ( bit_parite * 4 ) + ( longueur_donnees == 7 ? 0 : 2 ) + ( bit_arret ? 1 : 0 ) )[ "emgo\x95\x9D\x97\x9F\x85\x8D\x87\x8F" ] ) - 'a';

enough for me tonight, thank you again mate. You will be in my credit line for the help. :wink:

Wow, cool thank's it will be even eazer then i touth.

@ pYro_65,
DITTO.
Thanks for the link. I copied it and sent it to myself as an email so I can save it in my reference files.

No worries, I find myself looking at the core frequently to verify stuff.

@Frédéric_Plante, please do not delete posts. The code I wrote does not make sense without the 'real' if statement. It has little relevance to the 'if' I asked you for more info on.

So if people are wondering where I pulled the values from, here is the code.

	if (bit_parite == 0){

		if(longueur_donnees == 7){

			if (bit_arret == 0){configuration_UART=0x04}
			else if (bit_arret == 2){configuration_UART=0x0C}

		}

		if(longueur_donnees == 8){

			if (bit_arret == 0){configuration_UART=0x06}
			else if (bit_arret == 2){configuration_UART=0x0E}
		}

	}

	else if (bit_parite == 1){

		if(longueur_donnees == 7){
		
			if (bit_arret == 0){configuration_UART=0x34}
			else if (bit_arret == 2){configuration_UART=0x3C}

		}

		if(longueur_donnees == 8){

			if (bit_arret == 0){configuration_UART=0x36}
			else if (bit_arret == 2){configuration_UART=0x3E}

		}

	}

	else if (bit_parite == 2){

		if(longueur_donnees == 7){

			if (bit_arret == 0){configuration_UART=0x24}
			else if (bit_arret == 2){configuration_UART=0x2C}

		}

		if(longueur_donnees == 8){

			if (bit_arret == 0){configuration_UART=0x26}
			else if (bit_arret == 2){configuration_UART=0x2E}

		}

	}

I've done some post deletion of my own.

Keep it civil, the sin-bin beckons.

Thread locked