I have to transmit information from a uController to my Laptop. When I create the file I get the following error. I think it is easier to troubleshoot if you see the script.
Because it says that 'char [20]' in 'LPCWSTR' doesnt fit, I changed it like this:
CreateFile((LPCWSTR)name, GENERIC..
Now I can compile the program, but I still get INVALID_HANDLE_VALUE, and I'm not able to open the Port.
My Serial routine:
#include <stdlib.h>
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "com_bg.hpp"
char name[20]=""; //between the "" inserting COM"X"
...
do
{
port = CreateFile(name, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (port==INVALID_HANDLE_VALUE)
{
k++;
}
}
while ((k<MAXCREAT) && (port==INVALID_HANDLE_VALUE));
if (k==MAXCREAT)
return(ERR_COM);
...
My main Looks like this:
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <conio.h>
#include "com_bg.hpp"
#include "com._bg.cpp"
#include "tchar.h"
using namespace std;
int _tmain(int argc, _TCHAR *argv[])
{
printf("Hello\n");
getch();
err = openCom(8, 9600, NONE,1,RTSDTRLOW);
if (err != OK)
{
closeCom();
printf("Failed to OpenPort\n");
return 0;
}
…