Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Using Cattlerustler's MultiSerial DLL

Author
Message
BillR
19
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 12th Feb 2022 05:08
Hi Everyone,
Has anyone had any success using Cattlerustler's MultiSerial DLL to drive a USB port?
I have the DLL downloaded, have found no examples of how to use it.
I have just learned how to drive WS2812b RGB LEDs from an Arduino, and I want to output
from DBPro to the Arduino thru a USB port.
I sure could use some help here, and a programming example would be great of how to use the plugin.
Thanks in advance for any help in this matter!
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 12th Feb 2022 05:26
I can help you once I find the plugin. It shouldn't be anything difficult. If you have a link to the plugin, that would be helpful, in the meantime I'll search the forums.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 12th Feb 2022 05:29
I found the original post but the website link is dead unable to help.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
BillR
19
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 12th Feb 2022 06:08
Here is the Forum page for the link

https://forum.thegamecreators.com/thread/108446

BillR
19
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 12th Feb 2022 06:20
I think COM3 on my desktop computer is considered the USB port I am using.
I will be doing output only from the PC to the Arduino as far as I know,
sending bytes of data to the Arduino to be processed.

Thank you so very much for taking an interest in helping!
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 12th Feb 2022 06:34
got it, thanks for the link, will have a look and get back to you as soon as I can.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
BillR
19
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 12th Feb 2022 09:21
One more thing...
You will NEED the Microsoft .NET Framework 2.0 for the Plugin to work,
according to the DBP_SerialPortMulti_exp.doc when you uncompress the download.

Here is a web page describing how to do that for windows 7/8/10

https://customercare.primera.com/portal/en/kb/articles/how-to-enable-net-framework-2-0-and-3-5-in-windows-10-and-8-1


Hope this helps!
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 12th Feb 2022 09:29
yes I know and have that already, programming is my daily job , so am in the know , but thanks
USB does not get assigned a COM number , but an address. will see if this plugin works with USB, am out today so may have a play around tomorrow.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 13th Feb 2022 16:20
You need a USB-Serial adapter.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
BillR
19
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 15th Feb 2022 02:49
My Elegoo Arduino UNO R3 board is based on the Atmega328P.
It features the Atmega16U2 programmed as a USB-to-serial converter.
It allows my PC Windows 8.1 using USB(COM3) to download programs into my Arduino UNO which works fine.
I have written several programs playing around with the Arduino.
I'm hoping I can write a program on the Arduino to read data coming in on that same USB port from an outside source being DBPro,
setting the correct baud rate etc as a serial input port.
Documentation in the Arduino world seems to support that idea as feasible.
BillR
19
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 15th Feb 2022 08:22
I had originally hoped to download something like Cattlerustler's DLL,
Find some example DBPro code to show me what commands to use to output to the USB port to send data to my Arduino controller board.
Well, I couldn't find any example code, so I don't know what commands are in the DLL or how to use it.
So I'm hoping you are still willing to help me figure out what commands are in the DLL, and maybe how to start using them.
This is really Very important to me, so I'm hoping to get this working with your help if possible.
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 15th Feb 2022 09:54 Edited at: 15th Feb 2022 09:56
I can certainly help, For any DLL, you can find commands (if docs are not available), using Dependency Walker https://www.dependencywalker.com/

The commands are located in the DBP_SerialPortMulti_exp.doc file that came with the plugin. If you don't have it, it's attached here:

so if you are using COM3 , the id would be 'COM3' for the SPM_AddPort command, here are the commands in short that are also listed in the editor keywords DBP_SerialPortMulti_kw.ini file:

[LINKS]
SPM_AddPort=*none*=ByVal ID As String, ByVal Baud As Integer, ByVal DataBits As Integer, ByVal Parity As Integer, ByVal StopBits As Integer
SPM_ConfigurePort=*none*=ByVal ID As String, ByVal Hshake As Integer, ByVal RBSize As Integer, ByVal WBSize As Integer, ByVal RTSEnable As Integer, ByVal RTO As Integer, ByVal WTO As Integer, ByVal RBThreshold As Integer, ByVal DTREnable As Integer
SPM_OpenPort=*none*=ByVal ID As String
SPM_ClosePort=*none*=ByVal ID As String
SPM_OpenAll=*none*=
SPM_CloseAll=*none*=
SPM_RemovePort=*none*=ByVal ID As String
SPM_GetMachinePortNames=*none*=() As String
SPM_PortIsOpen=*none*=(ByVal ID As String) As Integer
SPM_GetCTSState=*none*=(ByVal ID As String) As Integer
SPM_DQNext=*none*=(ByVal ID As String) As String
SPM_Write=*none*=ByVal ID As String, ByVal sData As String

So your first port of call would be the SPM_AddPort command before you can do anything else. I'm trying to find time to play around with this as I don't have same setup as you.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
BillR
19
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 16th Feb 2022 05:38
Thanks!
Here is what I have so far...

Rem Project: Arduino Output-1
Rem Created: Tuesday, February 15, 2022

Rem ***** Main Source File *****

PORT$ = "COM3"
#CONSTANT BAUD = 9600
#CONSTANT BITS = 8
#CONSTANT PARITY = 0
#CONSTANT STOPBITS = 1

print "Start"
sync
gosub SPM_AddPort(PORT$, BAUD, BITS, PARITY, STOPBITS)
//gosub SPM_ConfigurePort() //not sure I know enough to use this yet
gosub SPM_OpenPort(PORT$)
gosub SPM_Write(PORT$, "ABCD")
gosub SPM_ClosePort(PORT$)
print "Done!"
sync
wait 3000
end

I get a Compile ERROR
User function 'SPM_AddPort' must return a value if used in an expression at line 14 (AddPort line)
Not sure what to do?
I'm using a gosub, and the .doc file does say something about VB wanting to return a value...
I've also tried a=SPM_AddPort, a$=SPM_AddPort, don't know how to handle a returning value from a gosub...help?
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 16th Feb 2022 07:30 Edited at: 16th Feb 2022 12:34
not a problem, the doc is not DBPro friendly. For a dll that's being used by DBPro, you only need to do the following:

e.g. success=SPM_AddPort ...

No need for gosubs, that's only used when calling a DBPro labelled subroutine e.g.:

GOSUB Mylabel

..
..

MYLABEL:

...

return


So you just need to remove the GOSUBS and return a value where a function requires it.

I will play around with a COM port on my PC when I get more time. Maybe I will get myself an Arduino board and see what it can do. Never heard of it until a little while ago.

The last time I had to program STOP BITS, PARITY, BAUD RATES etc was in the 80's when I first had an internet connection to BT's Microlink back in the day. This is really interesting, will have a look at cheap Arduino boards, if there are any.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 16th Feb 2022 08:40 Edited at: 16th Feb 2022 10:55
ok, it looks like there is no return value for the Add_Port function:

[edit-also remove the brackets, otheriwse the compiler complains it doesn't understand, brackets if it returns a value]
SPM_AddPort PORT$, BAUD, BITS, PARITY, STOPBITS

so in my case, I'm adding port COM1 which uses the same port settings as your COM3:



I can now parse my #constants through the AddPort function.

Moving onto next command(s), will get back to you as soon as possible, busy day ahead.

[EDIT=success with opening and closing port-so you should be good to go on writing to your COM3 port using "COM3" as your ID]


[EDIT2-calling the pnames$=SPM_GetMachinePortNames() will return a comma delimited string of all available COM ports for your OS]
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
BillR
19
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 20th Feb 2022 06:20
I've worked for days on this, so frustrating at times...
just getting the DLL commands to work was a freaking nightmare!
but...
IT FINALLY WORKS!!!
I'm outputting data from my PC over USB (COM3) using my DarkBASIC PRO program to my Arduino program,
which is receiving the data and processing it correctly!

I am so GRATEFUL to you!
I REALLY couldn't have done this without your help!
So, Your willingness to help me was Awesome!
Thank You Very Much!!!
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 20th Feb 2022 07:09
that's fantastic news. yes some dlls can be frustrating at times. glad it all worked out for you.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Login to post a reply

Server time is: 2023-02-06 00:06:13
Your offset time is: 2023-02-06 00:06:13