Convert char to byte c++ -


I trying to convert around one byte (Microsoft type, I'm working with Visual Studio) I am here. The fact is that I want to fill a structure for serial port communication and I'm getting back the information from .i file. Datas are saved in a four temporary buffer, requiring some value in the DCB port settings in the byte. I tried several ways without success. Datas are recovering from .ini but I have some problem in converting them into bytes.

I can convert numeric values ​​to integers, but they also have to be byte.

And process-> Read method is a subjective implementation of GetPrivateProfileString.

  set around [10]; Printf (read port settings \ n "" \ n ", comName); ProcessFileConfig-> Read (comName, "baudrate", "9600", res, sizeof (res)); Baud = atoy (rcc); ProcessFileConfig-> Read (comName, "parity", "n", res, sizeof (res)); Samata = (byte) ridge; Std :: cout & lt; & Lt; "Parity size:"; Std :: cout & lt; & Lt; Sizeof (parity) & lt; & Lt; Std :: endl; Std :: cout & lt; & Lt; "Content of Equality:"; Std :: cout & lt; & Lt; Parity & lt; & Lt; Std :: endl; ProcessFileConfig-> Read (comName, "bytesize", "8", reserve, size (ridge)); Byte size = auto (race); Std :: cout & lt; & Lt; "Take a small piece of piece:"; Std :: cout & lt; & Lt; Byte size & lt; & Lt; Std :: endl; ProcessFileConfig-> Reading (comName, "stopbits", "1", res, sizeof (res)); Stopbeats = Atoi (race); Std :: cout & lt; & Lt; "stop bits : "; Std :: cout & lt; & Lt; Stopbeats & lt; & Lt; Std :: endl; PortSettings.DCBlength = sizeof (port settings); PortSettings.BaudRate = baudr; // This is a fine portSettings.ByteSize = byte size; // Return port settings. Mercury = parity; // does not port anything settings Close = Close; // gives a smiley return :)  

and my file.ini example:

  [COM1] baudrate = 15000 ByteSize = 8 stopbits = 1 parametti = n  

Edit: Res gives good value from buffer .i, everything is fine on this side, the last three values ​​for the unsigned long (byte Seiz, stopbeat and parity) need to be replaced.

Your current code tries to convert buffer to a BYTE What you need to do is parse the buffer with strtoul () , and enter << code> BYTE .


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -