• Welcome to PiBoSo Official Forum. Please login or sign up.
 
March 28, 2024, 10:13:38 PM

News:

World Racing Series beta14 available! :)


Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Antian

1
Custom hardware / Re: Send values via USB to arduino??
September 13, 2020, 12:43:33 AM
Thanks h106frp and HornetMaX
I have it running...
2
Custom hardware / Re: Send values via USB to arduino??
September 10, 2020, 03:52:39 PM
Thank you H.
I've read the entire article and the one he links in that https://www.waitingforfriday.com/?p=415
Looking over the code, but it's going to take me a while to pick it apart as my coding ability isn't too much above "Hello World"  ;D
Slowly inching my way forward.
3
Custom hardware / Re: Send values via USB to arduino??
September 08, 2020, 01:59:28 AM
I doubt I'll get a reply on this question, but I'll ask anyway.
Has anyone made their own HID/PID device? I have lots of information about writing the descriptor but I'm missing information about how to write data from the host to the "OUTPUT pipe" back to microcontroller.
4
Custom hardware / Re: Send values via USB to arduino??
September 08, 2020, 01:44:47 AM
Thanks HornetMax,
Any information is helpful.
I've paused on the idea of sending data using strings through serial communication and started researching on creating a USB HID/PID device.
5
Custom hardware / Re: Send values via USB to arduino??
August 29, 2020, 04:58:32 PM
Hey everyone,
So while I'm researching the best way to send values over COM port to arduino,
thought I'd post this in case someone could stop me from digging too far into the wrong direction.
FYI codes below may not be typed up correctly... just throwing something up for talking points.

the writefile function expects char* value. So I need to convert int/float to char then send to arduino.
Arduino then receives and convert char back to int/float.
One example.
char* int2str(unsigned long num) {
static char retnum[21];
sprintf(retnum, "%ul", num)
return retnum;
}
Also have to write one for float conversion.

I read that using binary conversion is the best option, but only *IF* you know what you're doing,
and ascii is the easiest method but with overhead on the system (slower) or there's hex.
I'm not experienced so guess I'll go ascii.

So if I want to send an int... lets say m_iRPM and a float m_fSpeedometer or multiple values per loop, then I guess use a variable array such as:
float num [2][2];
num[0]= int(p->m_sData.m_iRPM);
num[1] = p->m_sData.m_fSpeedometer;

char* float2str(){
do some conversion;
return result;
}

float2str (num);

WriteFile(hFile,
float2str,
sizeof(float2str),
NULL,
NULL);

This sends char to arduino which then gets reversed back to respective values....??

Have not tried this... I'm just looking into possible options.
Am I even close to being on right path??
Thanks
6
Custom hardware / Re: Send values via USB to arduino??
August 26, 2020, 10:49:53 PM
Appreciate that H.
Which arduino model you using? May just buy that.
and I'll try code blocks just in case... I've use code blocks in the past some too. I'd be shocked if it was that.
Also do you mind sharing what arduino test code you used? In case I'm missing something.
7
Custom hardware / Re: Send values via USB to arduino??
August 26, 2020, 09:38:13 PM
#include <windows.h> & HANDLE is there (though not on the file I posted, sorry) without it would not compile.
8
Custom hardware / Re: Send values via USB to arduino??
August 26, 2020, 08:34:52 PM
:o  OK. so I tried hyperterminal and it read back the Serial.write function... "Value Read %d" ....of the teensy and the light started blinking as I instructed it to do (simple but hey). It was showing garbage when I typed for some reason and no returning data being sent back.
Though I still don't know if It's an error in the C code sending the data or what?
So the problem is I can't code  :-[
I was trying to keep it real simple.
9
Custom hardware / Re: Send values via USB to arduino??
August 26, 2020, 07:05:28 PM
The device default is COM3.
From my understanding is anything higher than COM9 requires the use of \ like (\\\\.\\COM10) anything less is just (COM#). I've used both with and without \'s no effect.
I can assign the device a different COM port to say 10,12,23.etc. and change my code to match but still no effect.
If the arduino serial monitor is open then it does cause in interrupt with connection, so I keep it closed.
I see this happen when using CreateFileA command stated earlier, which tells me its making some kind of COM connection(it sees the device).
My guess at this point would be there's a problem with how I'm telling it to send the data, or how I'm telling teensy to receive said data. All the tutorials I find and try to use end with same result. I'm trying to get help from the people over at teensy too.
I appreciate your time on this though H.
10
Custom hardware / Re: Send values via USB to arduino??
August 26, 2020, 04:34:02 PM
From what I can tell the all the drivers are installed and windows shows the device connected to COM3. If I unplug it, the "COM3" disappears. If thats what you mean.
I've used this device to even make a joystick that works with GPB, and everything runs fine that way. I have two of these boards and testing output data on one of them.(trying to)
FYI to be specific this is a teensy 3.2
Appreciate the help/info
11
Custom hardware / Re: Send values via USB to arduino??
August 26, 2020, 03:43:19 PM
Thank you for the information, all this is obviously over my head. I'll have to research what you've described.
My thinking is if I can send data back and forth to the arduino serial monitor software using just the usb cable then surely it's just a matter of changing where the data is coming from(i.e.: game values).
12
Custom hardware / Send values via USB to arduino??
August 26, 2020, 03:13:00 PM
Anyone have a good way of sending values (lets say m_fRoll) to arduino via USB and not udp?
I've tried using example codes but does not establish connection (com port 3 in my case).
Right now I'm simply trying to establish connection and send test data, so code is simplistic.
I've attached the C_code and Arduino test code. Any help very much appreciated.

The error I receive is microsofts HANDLE error _INVALID_HANDLE_VALUE code 2 which means _FILE_NOT_FOUND, in other words can't find device on com port 3.
I'm not sure if its a windows issue or the arduino. If I run this code as HANDLE port = CreateFile("COM3", ) .... no connection is established, but if I run as CreateFileA or as (L"COM3")... then it acts like a port is established but see no data going through. Microsoft says to only use CreateFile because it's a macro that will make the correct actions based on the device.