This line contains multiple errors:
CreateFile(port_name,GENERIC_READ|GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN,NULL);
port_name
is not initializeddwCreationDisposition
must be OPEN_EXISTING
for serial portsdwFlagsAndAttributes
should be 0 for serial ports
Try
LPWSTR port_name = L"COM1";
CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
I did not check the remaining code for other errors.
[UPDATE checking for more errors]
The byte size is a bit count:
int m_byte_size = 8;
CreateFile
returns
INVALID_HANDLE_VALUE
upon errors:
if (fd == INVALID_HANDLE_VALUE)