Recent

Author Topic: Little help with arduino/LazSerial/5dpo connection?  (Read 6400 times)

Urbanproof

  • Newbie
  • Posts: 5
Little help with arduino/LazSerial/5dpo connection?
« on: July 07, 2015, 01:35:48 pm »
Hi all, newbie asking dumb questions.

I have an Arduino Leonardo that simply sends strings "OK" or "NOT OK", and what I am trying to do, is read that string to Lazarus, and save it to a .cvs file with timestamp. For connection I have installed both 5Dpo and LazSerial components.
 
So far I am only trying to test connection, but every time I try to compile my project I get an error "Could not open device \\.\COM1" and a reference to sdposerial.pas line 233. I find it a little strange, since Arduino is connected via COM8. As far as I can tell, all settings are correct.

Somebody willing to help me a little?  ::)
« Last Edit: July 07, 2015, 03:19:50 pm by Urbanproof »

fred

  • Full Member
  • ***
  • Posts: 201
Re: Little help with arduino/LazSerial/5dpo connection?
« Reply #1 on: July 12, 2015, 03:11:09 pm »
Since the is no code my guess would be that you open the device COM1 but not COM8.
Perhaps set port fisrt and the open?

Urbanproof

  • Newbie
  • Posts: 5
Re: Little help with arduino/LazSerial/5dpo connection?
« Reply #2 on: July 13, 2015, 09:39:52 am »
Well there is not much code to blame.  :) I dragged the LazSerial element to form, configured it on the component editor, and added OnRxData event. On the code editor I added following code to the event: Memo1.Lines.Add(Serial.ReadData);

Should I configure the port also in code editor?

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: Little help with arduino/LazSerial/5dpo connection?
« Reply #3 on: July 13, 2015, 03:52:06 pm »
Did a quick test with an Arduino Uno that confirms your problem.
The problem lies in the fact that you can set 'Active' to true in the object inspector.
This is a bug because if you do that, the IDE opens the serial port, and your running program can no longer access that port hence the error message.
So in the object inspector set Active to false and programmatically set it to true.

The text of the error message is another bug: the error itself is correct because of the above.
But the serial port number is not right. It seems by default it always shows COM1, even if you set it up on a different port.

As far as the communications go: it seems the OnRxData fires incorrectly sometimes when there is no data to be processed.
Make sure to check for that.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Urbanproof

  • Newbie
  • Posts: 5
Re: Little help with arduino/LazSerial/5dpo connection?
« Reply #4 on: July 14, 2015, 02:01:53 pm »
Thank you, now I understand the problem, but I still can't solve it.  :D
I tried to set it active on FormCreate event with "LazSerial1.Active:=true;" and got same error.
Can you walk me through this please.  ::)

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: Little help with arduino/LazSerial/5dpo connection?
« Reply #5 on: July 14, 2015, 03:15:16 pm »
If you still get the error there is a problem with the COM port itself.
Check the windows device manager if you still have COM8 assigned for the Arduino.
I noticed that the virtual COM-port number changes sometimes, especially after you plug it in another USB port.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Urbanproof

  • Newbie
  • Posts: 5
Re: Little help with arduino/LazSerial/5dpo connection?
« Reply #6 on: August 06, 2015, 06:31:48 pm »
Thanks eny, solved it. I guess it doesn't work on my laptop because of hardware level security systems, works like charm on my desktop pc.

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: Little help with arduino/LazSerial/5dpo connection?
« Reply #7 on: August 08, 2015, 07:22:10 am »
Thanks eny, solved it. I guess it doesn't work on my laptop because of hardware level security systems, works like charm on my desktop pc.
nope, it does not make sense. There shouldn't be any hardware level security systems on any pc compatible be it laptop/desktop or any other device for that matter. As far as I can understand with out a closer inspection there might not be any rs232 circuit on the laptop and it is emulated through usb/hdi or something along those lines. Better check your hardware what it has and what it has not.

Urbanproof

  • Newbie
  • Posts: 5
Re: Little help with arduino/LazSerial/5dpo connection?
« Reply #8 on: August 08, 2015, 01:59:03 pm »
In fact, there are many USB protection systems against badUSB attacks. If not hardware level, at least low-level. I don't know if that was the problem in my case, but because it works on my desktop pc I lost my interest.  :D

 

TinyPortal © 2005-2018