Jump to content

[Hardware, Plugin] Arduino based physical display + serial port io+ tutorial (24-11-19)


Recommended Posts

HI ! First think it's an amazing idea this mod thanks you !

I've test the with the KSPIODemo13 and KSPSerialIO_Mac_Linux_Win_0.17.4-1

Arduino Uno R3. The 3 LEDS works perfectly, input buttons too. RCS/SAS Leds works.

My problem it's when i plug my I2C 20x4 Screen. The 5 leds stop working, LCD get 1 initale data and second line: ovfl

It's supose to do (0,0) RAlt (0.1) Alt.

after nothing work. :P

If i unplug the screen leds restart.

I2C is pluggued in A4/A5 VCC/GND

Part of my code:

Nothing else in code change and screen work without trouble in other projets o.O

Thanks for help =)

uh.. I've never used that library, but if you are using i2c, why do you need all those pins?

#define En_pin 2

#define Rw_pin 1

#define Rs_pin 0

#define D4_pin 4

#define D5_pin 5

#define D6_pin 6

#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);

- - - Updated - - -

Also are you trying to print in binary (base 2) with lcd.print(VData.RAlt, 2);?

Link to post
Share on other sites

Hey Zitronen,

at first i want really to say "Thank you!" for your work at http://forum.kerbalspaceprogram.com/threads/66393-Hardware-Plugin-Arduino-based-physical-display-serial-port-io-tutorial-%2806-Jun%29. This thread is so awesome!

I started to explore KSP just a week ago and already got a small multiplayer-server with 4 friends running. But now i want to explore more. :) So i just started researching on the web and found the interesting things about "Build your own spaceship with KSP and Arduino". Just a small idea, but i really got addicted to this building-thing. :) I went to the webstore and bought an Arduino MEGA 2560 R3, a LCD-Shield (2x20, 5 Buttons) and a 4-axis-analog Joystick. After the stuff got mailed i just had to realize that the Arduino MEGA 2560 R3 cant be used as a HID without flashing the bootloader. But then after a couple of hours i found the thread of Zitronen, which got me some hope back. :) Now i just try to make my stuff with a serial-connection instead of using it as a HID. :)

Things i have done so far:

- I have uploaded your KSPIODemo12 to my Arduino MEGA 2560. It has compiled without any problem.

- I have installed the KSPSerialIO_017_3-addon to my KSP (Version 1.0.4) and edited the config.xml to fit my serial-port (COM3).

- I have started the game and everytime i get to the launchpad or a spacecraft i can see, that the Arduino reboots. Looks like the connection just works, am i right?

What i will have to do:

- Reorder the pin-setup, because i have a LCD-Shield, which uses the pins allready. But i got many more pins on the MEGA, so i basically just have to go over the Arduino-Sketch.

- Use the LCD-Shield to display some data.

- I have oredered a 4 axis-joystick. Maybe i can get this monster to work with KSP over Serial. :)

Here are the Questions:

- Is there a way to "test" the Arduino-sketch in the IDE-Serial-Monitor? Maybe with some command or data i could send manually?

- Is there an ingame "menu" or something to the addon?

- Sometimes my serial-connection just stops working and i have to reconnect the Arduino to the ubs-port (USB 2.0). Is this normal?

Greetings Steve

Link to post
Share on other sites

Hi FreakPsych,

Welcome to the thread. Lots of fun happening here. To answer your questions:

1. No. The serial connection gets hogged by the plugin, so you cannot use it to output data. Best practice I have found is to program the output with known values (written in the code or read from an analog port hooked to a potmeter), then modify the program so it reads the value from KSP. A dedicated sandbox save and maybe hyperedit are your friends here, as they will allow you to some control over inputs when you test the final sketch.

2. Nope, it just works if it works. Otherwise, you might have to tweak the config in the gamedata\KSPserialIO subfolder (can't remeber exact location or filename, and at work PC)

3. It happens to me as well every now and then.

As for the 4-axis joystick, if it is based on rotary potmeters (like this one), it is very simple to connect. And I burn with envy, as they are hilariously expensive where I live.

May I suggest adding a throttle? I found it the single greatest addition of not flying with a keyboard.

Good luck with the project, and don't forget to keep us posted of your progress.

Link to post
Share on other sites

Thanks @Freshmeat. :)

That is just the joystick i have ordered. ^^ 4-axis, 1 button and 10k resistance. Got mine from aliexpress for 18$.

Today i got the pins resorted and some changes on the sketch-code to fit my ideas. :) Got a working LCD with live gamedata and some LEDs running. :)

Link to post
Share on other sites

Ok... Today at the office all went right. (Win 7 Professional). Now at my homelaptop (Windows 10 Pro) it seems, that the handshare is initialising, but somehow crashes. I can see, that the Arduino is rebooting twice when i connect to flightmode.

The strange part: Yesterday i tried the basic connection with the 3 LEDs and i thing it worked ...

Anyone has tried to use 17.3 and Demo12 on Win 10?

Link to post
Share on other sites

Has anyone tried to use the 17.3 with Demo12 on Windows 10?

...
[WRN 18:56:02.389] [HighLogic]: =========================== Scene Change : From LOADING to MAINMENU =====================
[LOG 18:56:04.459] AddonLoader: Instantiating addon 'SettingsNStuff' from assembly 'KSPSerialIO'
[LOG 18:56:04.468] KSPSerialIO: Loading settings... KSPSerialIO: Loading settings...
...
[LOG 18:56:04.480] KSPSerialIO: Default Port = COM3
[LOG 18:56:04.481] KSPSerialIO: Refreshrate = 0.2
[LOG 18:56:04.482] KSPSerialIO: BaudRate = 38400
[LOG 18:56:04.482] KSPSerialIO: Handshake Delay = 2500
[LOG 18:56:04.482] KSPSerialIO: Pitch Enable = 2
[LOG 18:56:04.482] KSPSerialIO: Roll Enable = 2
[LOG 18:56:04.482] KSPSerialIO: Yaw Enable = 2
[LOG 18:56:04.482] KSPSerialIO: Translate X Enable = 2
[LOG 18:56:04.482] KSPSerialIO: Translate Y Enable = 2
[LOG 18:56:04.482] KSPSerialIO: Translate Z Enable = 2
[LOG 18:56:04.482] KSPSerialIO: Wheel Steering Enable = 2
[LOG 18:56:04.482] KSPSerialIO: Throttle Enable = 2
[LOG 18:56:04.482] KSPSerialIO: Wheel Throttle Enable = 2
[LOG 18:56:04.482] KSPSerialIO: SAS Tol = 0.1
...
[WRN 18:58:13.649] [HighLogic]: =========================== Scene Change : From TRACKSTATION to FLIGHT (Async) =====================
...
[LOG 18:58:15.159] AddonLoader: Instantiating addon 'KSPSerialPort' from assembly 'KSPSerialIO'
[LOG 18:58:15.159] KSPSerialIO: Version 0.17.3
[LOG 18:58:15.159] KSPSerialIO: Getting serial ports...
[LOG 18:58:15.159] KSPSerialIO: Output packet size: 189/255
[LOG 18:58:15.159] KSPSerialIO: Found 2 serial ports
[LOG 18:58:15.159] KSPSerialIO: trying default port COM3
[LOG 18:58:19.184] KSPSerialIO: KSP Display not found
[LOG 18:58:19.184] KSPSerialIO: trying port \Device\USBSER000 - COM3
[LOG 18:58:23.214] KSPSerialIO: KSP Display not found
[LOG 18:58:23.214] AddonLoader: Instantiating addon 'KSPSerialIO' from assembly 'KSPSerialIO'
[LOG 18:58:23.244] ------------------- initializing flight mode... ------------------
...

Could this be a Win10-problem? This afternoon on my Win7 pc at the office all worked without any problem.

Link to post
Share on other sites
Could this be a Win10-problem? This afternoon on my Win7 pc at the office all worked without any problem.

I think the important thing to point out here, is that your office PC has Kerbal Space Program installed on it...

Beautiful. :cool:

I do hope you get everything working! Bugs suck! :confused:

Link to post
Share on other sites
I think the important thing to point out here, is that your office PC has Kerbal Space Program installed on it...

Beautiful. :cool:

I do hope you get everything working! Bugs suck! :confused:

I work as a freelancer. ;) So basically i can do what i want, as far as i get the jobs done in time. :P

Link to post
Share on other sites
Anyone has tried to use 17.3 and Demo12 on Win 10?

I've read a bit lately with people having trouble running KSP on windows 10.

Have you tried running as Administrator? (Go to the KSP folder, and right-click 'ksp.exe' -> Run as Administrator.

Link to post
Share on other sites
I've read a bit lately with people having trouble running KSP on windows 10.

Have you tried running as Administrator? (Go to the KSP folder, and right-click 'ksp.exe' -> Run as Administrator.

The game runs pretty smooth on Win 10. Even as normal user. (Yes, i tried Run as Admin and also compatible mode.) Also i changed the usb-cable. The Arduino IDE runs normal and the Arduino is programable under Win 10.

74    00:58:50.143    0.00010129    KSP.exe    IRP_MJ_CREATE                           COM3    SUCCESS    Port Opened    
75 00:58:50.143 0.00000580 KSP.exe IOCTL_SERIAL_SET_QUEUE_SIZE COM3 SUCCESS InSize: 512, OutSize: 1024
76 00:58:50.143 0.00048550 KSP.exe IOCTL_SERIAL_SET_BAUD_RATE COM3 SUCCESS Baud Rate: 38400
77 00:58:50.144 0.00000535 KSP.exe IOCTL_SERIAL_SET_RTS COM3 SUCCESS
78 00:58:50.144 0.00019188 KSP.exe IOCTL_SERIAL_SET_DTR COM3 SUCCESS
79 00:58:50.144 0.00049264 KSP.exe IOCTL_SERIAL_SET_LINE_CONTROL COM3 SUCCESS StopBits: 1, Parity: No, DataBits: 8
80 00:58:50.144 0.00000491 KSP.exe IOCTL_SERIAL_SET_CHARS COM3 SUCCESS EofChar: 0x4, ErrorChar: 0x15, BreakChar: 0x15, EventChar: 0x0, XonChar: 0x11, XoffChar: 0x13
81 00:58:50.144 0.00000491 KSP.exe IOCTL_SERIAL_SET_HANDFLOW COM3 SUCCESS ControlHandShake: 0x1, FlowReplace: 0x80000040, XonLimit: 51, XoffLimit: 51
82 00:58:50.144 0.00000491 KSP.exe IOCTL_SERIAL_SET_TIMEOUTS COM3 SUCCESS ReadIntervalTimeout: -1, ReadTotalTimeoutMultiplier: 0, ReadTotalTimeoutConstant: 0, WriteTotalTimeoutMultiplier: 0, WriteTotalTimeoutConstant: 5000
83 00:58:50.145 0.00001696 KSP.exe IOCTL_SERIAL_SET_WAIT_MASK COM3 SUCCESS Mask: RXCHAR RXFLAG TXEMPTY CTS DSR RLSD BREAK ERR RING
84 00:58:50.145 2.50050692 KSP.exe IOCTL_SERIAL_WAIT_ON_MASK COM3 SUCCESS
85 00:58:52.646 0.00028737 KSP.exe IRP_MJ_WRITE COM3 SUCCESS Length: 8, Data: BE EF 04 00 01 02 03 04
86 00:58:52.646 0.00006649 KSP.exe IOCTL_SERIAL_SET_WAIT_MASK COM3 SUCCESS Mask: RXCHAR RXFLAG TXEMPTY CTS DSR RLSD BREAK ERR RING
87 00:58:52.646 1.53899197 KSP.exe IOCTL_SERIAL_WAIT_ON_MASK COM3 CANCELLED
88 00:58:54.185 0.00047880 System IRP_MJ_CLOSE COM3 SUCCESS Port Closed

This is what the serial ports data is. The code above run 2 times and then stops trying to connect. I have checked my sketch multiple times and even tried the last 3 versions of the plugin and democode. :) (All runs on Win7 without any problem!)

If i noticed right: On the Arduino only the RX-LED blinks on the connection try. The TX-LED does nothing at all.

I guess its something in Win 10. Maybe there is a Runtime change or something... I dont know. ^^

Link to post
Share on other sites

I'm having trouble running it on a new install under Windows 10 too. :/ No problems at all running the game, but the serial connection is not established. Have tried Windows 8 compatibility mode with no luck. Am hoping it's something simple and rebuilding the plugin on a Windows 10 machine will be enough to get it running.

Link to post
Share on other sites

I think i have found something: The SerialPort.dll (http://sourceforge.net/projects/serialportnet/) used in the plugin is written in c# and implements complete .NET 2.0 specifications. In Windows 10 there seems to be only .NET 3.5 and higher. No .NET 2.0 support anymore.

So we need to find a way to a) run .NET 2.0 on Win10 or B) get a "new" SerialPort.dll for a higher .NET version.

Link to post
Share on other sites

It targets 2.0? Huh. I'd assumed it would be 3.5 as well.

At any rate, I've installed .NET 3.5 (which also pulls in 2.0 and 3.0). It's available in the Windows Features install guy. Doesn't seem to have helped me, but I'm checking to make sure I've got the right versions of everything.

Link to post
Share on other sites
Oh dear.. that's going to be a pain in the ass, I don't have windows 10.

I re-compiled serialport.dll targeting .net 4.5, seems to work fine on win7, no idea if it will work in 10:

https://sites.google.com/site/zitronfiles/SerialPort4_5.zip

If this doesn't work I have no idea what to do...

I have tested it: Does not work. :( But thanks for trying.

I think its at the point where the Addon is searching for the com-port. I can see that there is RX once for a splitsecond on the arduino and then about 1-2 seconds TX sending while the addon is trying "COM3". Then the arduino reboots and the second com-port "\Device\USBSER000 - COM3" is beeing tested with the same routine. Both times the return message is "KSP Display not found".

I have posted the serial log from my port a few postings before: As we can see there, there is somehow data transmitted. My C#-skills are very low, so i cant tell whats wrong at this point, but i think its somehow the waiting for the "KSP Display Check"-check. Maybe we got wrong data (see log) or the time the addon is waiting for response is too low / skipped.

Tomorrow i will try to make a portlog of my win7 device to compaire it with the win10 log. :)

Link to post
Share on other sites

Sorry I don't have any time to test it further at the moment. I'm taking my controller to a maker faire next week(!!!), and just needed something that works. Happy to reinstall Win10 after that if there's anything I can do to get to the bottom of it.

Link to post
Share on other sites
I have tested it: Does not work. :( But thanks for trying.

I think its at the point where the Addon is searching for the com-port. I can see that there is RX once for a splitsecond on the arduino and then about 1-2 seconds TX sending while the addon is trying "COM3". Then the arduino reboots and the second com-port "\Device\USBSER000 - COM3" is beeing tested with the same routine. Both times the return message is "KSP Display not found".

I have posted the serial log from my port a few postings before: As we can see there, there is somehow data transmitted. My C#-skills are very low, so i cant tell whats wrong at this point, but i think its somehow the waiting for the "KSP Display Check"-check. Maybe we got wrong data (see log) or the time the addon is waiting for response is too low / skipped.

Tomorrow i will try to make a portlog of my win7 device to compaire it with the win10 log. :)

From the logs, it looks like it might be that it finds the serial ports, but is not receiving any reply from arduino. Have you tried handshake delay time in the config file at all?

Link to post
Share on other sites
From the logs, it looks like it might be that it finds the serial ports, but is not receiving any reply from arduino. Have you tried handshake delay time in the config file at all?

Yes, i have tried some settings, but with no luck so far. :) I can play at Win7 so its not a big deal. :)

I just provide much data as i can, because i have fun to debug such problems. ;)

[COLOR=#333333]01    00:58:50.143    0.00010129    KSP.exe    IRP_MJ_CREATE                           COM3    SUCCESS    Port Opened    [/COLOR]75    00:58:50.143    0.00000580    KSP.exe    IOCTL_SERIAL_SET_QUEUE_SIZE             COM3    SUCCESS    InSize: 512, OutSize: 1024    
02 00:58:50.143 0.00048550 KSP.exe IOCTL_SERIAL_SET_BAUD_RATE COM3 SUCCESS Baud Rate: 38400
03 00:58:50.144 0.00000535 KSP.exe IOCTL_SERIAL_SET_RTS COM3 SUCCESS
04 00:58:50.144 0.00019188 KSP.exe IOCTL_SERIAL_SET_DTR COM3 SUCCESS
05 00:58:50.144 0.00049264 KSP.exe IOCTL_SERIAL_SET_LINE_CONTROL COM3 SUCCESS StopBits: 1, Parity: No, DataBits: 8
06 00:58:50.144 0.00000491 KSP.exe IOCTL_SERIAL_SET_CHARS COM3 SUCCESS EofChar: 0x4, ErrorChar: 0x15, BreakChar: 0x15, EventChar: 0x0, XonChar: 0x11, XoffChar: 0x13
07 00:58:50.144 0.00000491 KSP.exe IOCTL_SERIAL_SET_HANDFLOW COM3 SUCCESS ControlHandShake: 0x1, FlowReplace: 0x80000040, XonLimit: 51, XoffLimit: 51
08 00:58:50.144 0.00000491 KSP.exe IOCTL_SERIAL_SET_TIMEOUTS COM3 SUCCESS ReadIntervalTimeout: -1, ReadTotalTimeoutMultiplier: 0, ReadTotalTimeoutConstant: 0, WriteTotalTimeoutMultiplier: 0, WriteTotalTimeoutConstant: 5000
09 00:58:50.145 0.00001696 KSP.exe IOCTL_SERIAL_SET_WAIT_MASK COM3 SUCCESS Mask: RXCHAR RXFLAG TXEMPTY CTS DSR RLSD BREAK ERR RING
10 00:58:50.145 2.50050692 KSP.exe IOCTL_SERIAL_WAIT_ON_MASK COM3 SUCCESS
11 00:58:52.646 0.00028737 KSP.exe IRP_MJ_WRITE COM3 SUCCESS Length: 8, Data: BE EF 04 00 01 02 03 04
12 00:58:52.646 0.00006649 KSP.exe IOCTL_SERIAL_SET_WAIT_MASK COM3 SUCCESS Mask: RXCHAR RXFLAG TXEMPTY CTS DSR RLSD BREAK ERR RING
13 00:58:52.646 1.53899197 KSP.exe IOCTL_SERIAL_WAIT_ON_MASK COM3 CANCELLED
[COLOR=#333333]14 00:58:54.185 0.00047880 System IRP_MJ_CLOSE COM3 SUCCESS Port Closed[/COLOR]

I still try to understand the way of communication:

Step 01: The PC opens the Serial-Port and does his setup of parameters (Line 01-08)

Step 02: The PC starts listening on the Port for 2.5 seconds for incomming Handshakes. (Line 09-10)

Step 03: The PC sends a Handshake to the Arduino and starts waiting for a reply. (Line 11-12)

Step 04: The PC stops listening for a repy after 1.5 seconds. (Line 13+14)

Is this right?

In the config.xml i can find a HandshakeDelay setting (Tried some values up to 10 seconds. It seems to control the Step 02 above.), but no setting "for the waiting for response"-time (Which is Step 04 above, i guess).

BTW: Have fun at the makers fair. :)

Link to post
Share on other sites
Yes, i have tried some settings, but with no luck so far. :) I can play at Win7 so its not a big deal. :)

I just provide much data as i can, because i have fun to debug such problems. ;)

[COLOR=#333333]01    00:58:50.143    0.00010129    KSP.exe    IRP_MJ_CREATE                           COM3    SUCCESS    Port Opened    [/COLOR]75    00:58:50.143    0.00000580    KSP.exe    IOCTL_SERIAL_SET_QUEUE_SIZE             COM3    SUCCESS    InSize: 512, OutSize: 1024    
02 00:58:50.143 0.00048550 KSP.exe IOCTL_SERIAL_SET_BAUD_RATE COM3 SUCCESS Baud Rate: 38400
03 00:58:50.144 0.00000535 KSP.exe IOCTL_SERIAL_SET_RTS COM3 SUCCESS
04 00:58:50.144 0.00019188 KSP.exe IOCTL_SERIAL_SET_DTR COM3 SUCCESS
05 00:58:50.144 0.00049264 KSP.exe IOCTL_SERIAL_SET_LINE_CONTROL COM3 SUCCESS StopBits: 1, Parity: No, DataBits: 8
06 00:58:50.144 0.00000491 KSP.exe IOCTL_SERIAL_SET_CHARS COM3 SUCCESS EofChar: 0x4, ErrorChar: 0x15, BreakChar: 0x15, EventChar: 0x0, XonChar: 0x11, XoffChar: 0x13
07 00:58:50.144 0.00000491 KSP.exe IOCTL_SERIAL_SET_HANDFLOW COM3 SUCCESS ControlHandShake: 0x1, FlowReplace: 0x80000040, XonLimit: 51, XoffLimit: 51
08 00:58:50.144 0.00000491 KSP.exe IOCTL_SERIAL_SET_TIMEOUTS COM3 SUCCESS ReadIntervalTimeout: -1, ReadTotalTimeoutMultiplier: 0, ReadTotalTimeoutConstant: 0, WriteTotalTimeoutMultiplier: 0, WriteTotalTimeoutConstant: 5000
09 00:58:50.145 0.00001696 KSP.exe IOCTL_SERIAL_SET_WAIT_MASK COM3 SUCCESS Mask: RXCHAR RXFLAG TXEMPTY CTS DSR RLSD BREAK ERR RING
10 00:58:50.145 2.50050692 KSP.exe IOCTL_SERIAL_WAIT_ON_MASK COM3 SUCCESS
11 00:58:52.646 0.00028737 KSP.exe IRP_MJ_WRITE COM3 SUCCESS Length: 8, Data: BE EF 04 00 01 02 03 04
12 00:58:52.646 0.00006649 KSP.exe IOCTL_SERIAL_SET_WAIT_MASK COM3 SUCCESS Mask: RXCHAR RXFLAG TXEMPTY CTS DSR RLSD BREAK ERR RING
13 00:58:52.646 1.53899197 KSP.exe IOCTL_SERIAL_WAIT_ON_MASK COM3 CANCELLED
[COLOR=#333333]14 00:58:54.185 0.00047880 System IRP_MJ_CLOSE COM3 SUCCESS Port Closed[/COLOR]

I still try to understand the way of communication:

Step 01: The PC opens the Serial-Port and does his setup of parameters (Line 01-08)

Step 02: The PC starts listening on the Port for 2.5 seconds for incomming Handshakes. (Line 09-10)

Step 03: The PC sends a Handshake to the Arduino and starts waiting for a reply. (Line 11-12)

Step 04: The PC stops listening for a repy after 1.5 seconds. (Line 13+14)

Is this right?

In the config.xml i can find a HandshakeDelay setting (Tried some values up to 10 seconds. It seems to control the Step 02 above.), but no setting "for the waiting for response"-time (Which is Step 04 above, i guess).

BTW: Have fun at the makers fair. :)

Yeah that is correct. The handshake delay is there because we need to wait for the arduino to restart when the serial port is open. After the restart the handshake reply from arduino should be immediate, so 1.5 seconds should be more than enough...

To the people using win 10, can you try adding some debug stuff into the Handshake() fucntion in the arduino code to turn on a LED, or maybe print something on LCD to make sure that the handshake packet is actually being sent?

Link to post
Share on other sites
Yeah that is correct. The handshake delay is there because we need to wait for the arduino to restart when the serial port is open. After the restart the handshake reply from arduino should be immediate, so 1.5 seconds should be more than enough...

To the people using win 10, can you try adding some debug stuff into the Handshake() fucntion in the arduino code to turn on a LED, or maybe print something on LCD to make sure that the handshake packet is actually being sent?

Will try it this evening. :) Just 3 more hours work to do, then the fun goes on. :P

---

So i put a LED behind the Handshake and it flashes every time it should. :)

---

Ok, i have just tried to hook up between the serial handshake and copied all data to my lcd.

void KSPBoardSendData(uint8_t * address, uint8_t len){

uint8_t CS = len;
lcd.clear();
Serial.write(0xBE);
lcd.setCursor(0, 0);
lcd.print(0xBE);
Serial.write(0xEF);
lcd.setCursor(4, 0);
lcd.print(0xEF);
Serial.write(len);
lcd.setCursor(8, 0);
lcd.print(len);
lcd.setCursor(0, 1);

for(int i = 0; i<len; i++){
CS^=*(address+i);
Serial.write(*(address+i));
lcd.print(*(address+i));
lcd.print(" ");
delay(750);
}

Serial.write(CS);
lcd.setCursor(13, 1);
lcd.print(CS);
}

The Display shows me: 190 239 4 0 3 1 4, then switches to 190 239 25 <25 Numbers>

This runs 2 times, because the Arduini is checked on 2 serialports. k_smiley.gif

If i convert the numbers into hex it will be: BE EF 04 03 01 04

I guess the first number row is the handshake and the second row is some kind of data (maybe button states or something).

Also i tried different timeout settings: everyting from 500 and more will give the same result. I have tried 500 - 10000 in 500ms steps. k_smiley.gif

Edited by FreakPsych
Link to post
Share on other sites

Ok, so the serial port is sending the correct handshake request to the arduino, and arduino is responding correctly, but some how the plugin is not receiving properly.

A couple of things to try:

1. What if you just add a delay in the handshake() function before KSPBoardSendData(details(HPacket)); of say 500ms? Anythng less than 1.5 seconds should work.

2. Try running this code which basically spams the handshake reply:


byte handshake[8] = {0xBE, 0xEF, 0x04, 0x00, 0x03, 0x01, 0x04, 0x02};

void setup() {
Serial.begin(38400);
}

void loop() {
for (byte k = 0; k < 8; k++) {
Serial.write(handshake[k]);
}

delay(20);
}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...