PC to USB SERIAL interface

Status
Not open for further replies.

LERAY

Well-known member
Helle all,
I'm planning to connect a TEENSY 3.2 or 5 to a PC.
Teensy is declared as SERIAL
Sytem configuration indicates COM16, but the CreateFile() function don't recognizes this port nor another port under WIN XP.
Under WIN 10, there is no COM port indicated by the system.
I'm using the USBDeview.exe for reading the available USB ports.
Thanks for your help !
-----------------------------------------------------------------------------------------------------------
SOURCE CODE
-----------------------------------------------------------------------------------------------------------


#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

//To cross-compile on Ubuntu:
//sudo apt-get install mingw32 mingw32-binutils mingw32-runtime
//i586-mingw32msvc-gcc -s -O3 -Wall -o serial_read.exe serial_read.c

const char *begin_string="10 second speed test begins";
const char *end_string="done!\r\n";
#define END_LEN 7

long i;
char data;
int numport;
char carsynchro = {'@'};

int main(void)
{

char bufferout[8] = {1,2,3,4,5,6,7,8};
HANDLE port;
COMMTIMEOUTS timeout;
COMMCONFIG cfg;
BOOL ret;
DWORD n,sum=0;

char com[16][32]={"COM16","COM1","COM2","COM3","COM4","COM5","COM6","COM7"};


// TODO: check if the user typed "COM##" where the number is
// greater than 9. If so, automatically reformat to \\.\COM##

// Open the serial port

for(numport = 0;numport<16;numport++)
{
port = CreateFile((char*)&com[numport][0], GENERIC_READ | GENERIC_WRITE,0, 0,OPEN_EXISTING, 0, NULL);

if (port == INVALID_HANDLE_VALUE)
{
exit(1);
}
else
goto porttrouve;
}


exit(900);
porttrouve:
// Configure the port
GetCommConfig(port, &cfg, &n);
cfg.dcb.BaudRate = 115200;
cfg.dcb.fBinary = TRUE;
cfg.dcb.fParity = FALSE;
cfg.dcb.fOutxCtsFlow = FALSE;
cfg.dcb.fOutxDsrFlow = FALSE;
cfg.dcb.fDtrControl = DTR_CONTROL_ENABLE;
cfg.dcb.fDsrSensitivity = FALSE;
cfg.dcb.fTXContinueOnXoff = TRUE;
cfg.dcb.fOutX = FALSE;
cfg.dcb.fInX = FALSE;
cfg.dcb.fErrorChar = FALSE;
cfg.dcb.fNull = FALSE;
cfg.dcb.fRtsControl = RTS_CONTROL_ENABLE;
cfg.dcb.fAbortOnError = FALSE;
cfg.dcb.XonLim = 0x8000;
cfg.dcb.XoffLim = 20;
cfg.dcb.ByteSize = 8;
cfg.dcb.Parity = NOPARITY;
cfg.dcb.StopBits = ONESTOPBIT;
SetCommConfig(port, &cfg, n);
GetCommTimeouts(port, &timeout);
timeout.ReadIntervalTimeout = 250;
timeout.ReadTotalTimeoutMultiplier = 1;
timeout.ReadTotalTimeoutConstant = 500;
timeout.WriteTotalTimeoutConstant = 2500;
timeout.WriteTotalTimeoutMultiplier = 1;
SetCommTimeouts(port, &timeout);

// WRITEdata until we get a timeout or error or see the end string

ret = WriteFile(port,bufferout,8,&n,NULL);

fflush(stdout);

CloseHandle(port);

return 0;
}
 
Usb 3.6 usb problem

Hello all,

TEENSY 3.6 controlling the Techtoys video board 8876 is running fine ONLY WHEN THE Teensy micro-USB1 plug is connected to a PC/USB 2.0
(For information, the USB Host 5 pins connector (I call it USB2) is connected to the Tactile Screen USB output).
When I try to connect the USB1 to a simple USB supply (no longer the PC), the Teensy don't runs. Strange.
Because absolutely no program running on the PC is necessary for running my Teensy program. (Except the 5V supply replaced by a 5V classic USB charger!).
Thanks for your help !
Best regards,
Pascal Leray
 
USB HOST PORT as Touchscreen Input TEENSY 3.6

Glad that it works :)
Hello all,

When I connect the TEENSY 3.6 USB HOST port to a touchscreen USB output with a BUYDISPLAY HDMI screen , all is running fine.
But with another touchscreens such as the svga LG FLATRON T1710, no response.
Of course, this screen runs normally with a PC.
Thanks for your help !

Pascal Leray
 
Hello all,

When I connect the TEENSY 3.6 USB HOST port to a touchscreen USB output with a BUYDISPLAY HDMI screen , all is running fine.
But with another touchscreens such as the svga LG FLATRON T1710, no response.
Of course, this screen runs normally with a PC.
Thanks for your help !

Pascal Leray

I tried also with an ASUS VT207 : no response too. Is anyone has infos about Touchscreen USB interfaces ? Can we test something with the TEENSY 3.6 ?
 
Status
Not open for further replies.
Back
Top