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 / Serial Port Multi

Author
Message
Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 2nd May 2014 01:06
Hi everyone. I am searching for examples on how to use Cattle Rustler's Serial Port Multi.
I have looked through the threads and found indirect references.
I also found an example on how to use KERNEL32.
Has anyone some sample code? Or recomendations on which method is the simplest?
Thanks for reading.
Mark
ps I have the documentation that came with the plugin.
Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 3rd May 2014 01:08
Ok to show I am serious. This is a slow long term goal.
I purchased the TRUERNG
http://ubld.it/products/truerng-hardware-random-number-generator/

I am getting it to work with DBPro but am stuck between Cattle Rustlers method and using KERNEL32.
The threads I have read through are all closed.

I have tested the device with the proggie RealTerm so I know it works.
Does anyone have any insight?
Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 3rd May 2014 02:15
Ok a more specific question.

in DBP_SerialPortMulti_kw.ini for the function to add a port it says:

Quote: "SPM_AddPort=*none*=ByVal ID As String, ByVal Baud As Integer, ByVal DataBits As Integer, ByVal Parity As Integer, ByVal StopBits As Integer"


and in dbpro I write:

ID AS STRING = "COM2"
Baud AS INTEGER = 9600
DataBits AS INTEGER = 128
Parity AS INTEGER = 1
StopBits AS INTEGER = 1

SPM_ADDPORT(ID, Baud, DataBits, Parity, StopBits)

and the compiler says that it could not understand.
Seditious
10
Years of Service
User Offline
Joined: 2nd Aug 2013
Location: France
Posted: 4th May 2014 18:49
I'm sorry I can't help you since I don't have much experience in this area, but:

Quote: "SPM_ADDPORT(ID, Baud, DataBits, Parity, StopBits)

and the compiler says that it could not understand."


You only use brackets on a function when returning a value (or if it's a user-defined function). Otherwise you should call it like this;

SPM_ADDPORT ID, Baud, DataBits, Parity, StopBits
VisualProg
15
Years of Service
User Offline
Joined: 31st Mar 2009
Location: RussianFederation, Smolensk
Posted: 5th May 2014 15:30
Quote: "and the compiler says that it could not understand."

No entry point "SPM_AddPort" in your dll. Or this dll is not have correctly tuning.
You scan all entry points and find need function.

Use WinApi. This very simple:

Source code in VisualBasic 6.0


You can translete this code in c++ and create dll, or can use Api from BDP.

MZh[NUL] <--
Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 6th May 2014 22:38 Edited at: 6th May 2014 22:39
Here are the files I am working with using By CattleRustler's work.

In the attached .doc it says
"Sub SPM_AddPort(ByVal ID As String, _
ByVal Baud As Integer, _
ByVal DataBits As Integer, _
ByVal Parity As Integer, _
ByVal StopBits As Integer)"

I am unsure on how to translate that into a dbpro dll call.

Attachments

Login to view attachments
Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 6th May 2014 22:52
this other method lifted from Ben_UK78 slow crashes my pc.
http://forum.thegamecreators.com/?m=forum_view&t=186660&b=1

code:
VisualProg
15
Years of Service
User Offline
Joined: 31st Mar 2009
Location: RussianFederation, Smolensk
Posted: 6th May 2014 22:53
Quote: "I am unsure on how to translate that into a dbpro dll call. "

SPM_ADDPORT%SLLLL%SPM_AddPort%ID,Baud,DataBits,Parity,StopBits

=> point entry = "void SPM_AddPort(LPSTR,int,int,int,int)"

use in dbp:


result - err message.

You use "128", but this dll read "constant index" value "5","6","7" or "8".
Read manual, you missed something.

MZh[NUL] <---

Attachments

Login to view attachments
Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 6th May 2014 22:55
Thank you VisualProg.

Yes I missed something. And when I fix that I will realize I missed another thing.

I will test that code.
VisualProg
15
Years of Service
User Offline
Joined: 31st Mar 2009
Location: RussianFederation, Smolensk
Posted: 6th May 2014 23:04
Quote: "DataBits is the amount of data bits per byte (ie 5 thru 8), Parity see Enumerated Constants chart above for this argument"

funny, but that the table has no values ​​DataBits)

Quote: "Thank you VisualProg."

Not at all))

MZh[NUL] <---

Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 6th May 2014 23:10


this code works. I have to find out how to return the value so I can use it.

Thanks again.
VisualProg
15
Years of Service
User Offline
Joined: 31st Mar 2009
Location: RussianFederation, Smolensk
Posted: 7th May 2014 09:03 Edited at: 7th May 2014 09:06
Quote: " I have to find out how to return the value so I can use it."

what is value?

If you need read from com port, you open his and receive data. (wait and see to buffer)

Function "SPM_DQNext" in dll return UInt32 format (http://msdn.microsoft.com/en-us/library/system.uint32.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1) this "unsigned int" => additional conversion is not required.

I can not test, but in theory it should read data from the port:


MZh[NUL] <---

Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 8th May 2014 00:24
Thanks for the help again VisualProg.
I like the way you use functions as part of an argument. It took me a little time to understand.
I made some small corrections.
I also added "print chr$(buff)" in your function ReadBuffer. This program works because it doesn't crash.
It doesn't work because the screen is blank.
I also inserted 'print res' within the repeat until loop.


Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 8th May 2014 00:25
I don't have a lot of coding time atm. I will get this done and thanks again for your help.
Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 8th May 2014 01:44
This prints a 0.

Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 8th May 2014 03:23
I think it's 'working' now. At least it appears to be adding values together.
I had to add SPM_ConfigurePort to the code.

Attachments

Login to view attachments
VisualProg
15
Years of Service
User Offline
Joined: 31st Mar 2009
Location: RussianFederation, Smolensk
Posted: 8th May 2014 11:43 Edited at: 8th May 2014 13:45
Quote: "wait 1000"

o_O? this dll requires using low-level rules for com ports?
Then, the spread of 200-350 milliseconds for data-arrival. 1000 - the end of translation unit. (But then the meaning is lost use the "queue.")

I am not understand what this dll used, or all at a high level (only need to read data from the buffer) or low (need to read the data, combine all in rows, waiting for the end of the broadcast)

About the image: you get big numbers (must 0-255), maybe it's "strings". Try use it:


When you will complete to the code, can you show this here? It wonder for me))

MZh[NUL] <---

Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 10th May 2014 00:29
The WAIT command is so I can watch the output looking for patterns.
I found the attachment as a reference. It's a .h file that gives C commands to how to operate this unit. I only need the getByte() command.
It might be easier overall to create my own dll.

Attachments

Login to view attachments
Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 10th May 2014 00:31
This is the output that I am after:

"B933929EBAD56FED9E2D91456AC6005EB7BDA355550618C68BA12DB3B241E4FD85B664860345B571464E7767474834FD6BC23CAF9A9DB4EDA1BAB49B362B1551432F0B03C58743B168DD049E26C014961149636C5C28815FA3F8A22EE9A33307ABAB91AFB93207C4E87914017AC2AE04D0D7A7679BB1B3CFEEAFD49D0CA768DB0AA21E8809B77E467A6B4E5EE387A7163D36D2B1BD4B1768AB65952096CFD7899AA59D040D0488DABACAE4FE573CE7A47CAB9E393CEEB6448B" etc.

Attachments

Login to view attachments
VisualProg
15
Years of Service
User Offline
Joined: 31st Mar 2009
Location: RussianFederation, Smolensk
Posted: 10th May 2014 15:44
Quote: "function _DQNext(PortID As String)
local result AS INTEGER
result = call dll (dll_num,"SPM_DQNext", PortID) ` send only PortID, get chr$-summ
print result
wait 1000
endfunction result"

I have not noticed, you need to string and not integer:


Quote: "It might be easier overall to create my own dll. "

maybe)

Quote: "I only need the getByte() command. "

you can create and export functions for initialization port and read byte.

MZh[NUL] <---

Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 12th May 2014 11:08
Here is the output.

and the code.



Attachments

Login to view attachments
Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 12th May 2014 11:39
Thanks for your help again VisualProg.

I started another thread to go the c++/dll route.
http://forum.thegamecreators.com/?m=forum_view&t=211048&b=20&p=0
Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 14th May 2014 11:32
I found a solution here:
http://forum.thegamecreators.com/?m=forum_view&t=87450&b=1

I will post back to this thread when I have something.
Likely more questions.
here is the code I am using.

Mdj
12
Years of Service
User Offline
Joined: 11th Mar 2012
Location: The Shire
Posted: 20th May 2014 10:58 Edited at: 20th May 2014 11:01
I got it working. Slowly I am stripping down the original and bending it to my other functions.

It writes random bytes to a file and the screen. The bytes generated by this usb device appear to be more random than what is normally available on pc's. I haven't tested that personally yet.

Thanks for the help.
Attached is sample output.
Code is below.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-04 03:10:02
Your offset time is: 2024-05-04 03:10:02