Jump to content


Photo

Rs232 #2


  • Please log in to reply
59 replies to this topic

#1 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 29 October 2007 - 10:40 PM

I'm back and using GM again... it's been a while. Since I’ve gotten a number of Emails asking about the RS232 DLL, I figured I would rewrite it and support it again.

So, this new version of the DLL has a bunch of different functions (I lost the old source code so I just rewrote it from scratch)
Most importantly is the addition of a SetTimeouts function which allows you to specify how long a read/write function should wait before returning (this way, the read functions won't hang if there’s no input.)

It's available as both a DLL with scripts and a GM7 extension. Small examples for each are included.
Download it here: RS232DLL.zip

EDIT: Added a flow control function.

Enjoy
-Andrew

Edited by andbna, 19 January 2008 - 03:59 AM.

  • 1
GMBullet- Take advantage of the powerful Bullet Physics library.

#2 Mister_M

Mister_M

    GMC Member

  • New Member
  • 499 posts

Posted 29 October 2007 - 11:35 PM

Wow a timeout system! Just what i needed!
Thanks!
  • 0

#3 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 30 October 2007 - 04:44 AM

Your most welcome :lol:

and, It appears I made a few typos in the GM6 script. It's been fixed now :D

Cheers
-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#4 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 30 October 2007 - 02:07 PM

The previous version wasn't able to communicate with my RS232 microcontroller. Lets see if this one works!
  • 0

#5 contactnero

contactnero

    GMC Member

  • GMC Member
  • 12 posts

Posted 07 January 2008 - 07:15 PM

The previous version wasn't able to communicate with my RS232 microcontroller. Lets see if this one works!

<{POST_SNAPBACK}>


So, is this version able to communicate with your RS232 microcontroller?
  • 0

#6 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 14 January 2008 - 01:17 AM

.

Edited by FlipSide, 16 October 2009 - 01:46 AM.

  • 0

#7 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 14 January 2008 - 11:22 PM

The order is detailed in the Help.txt It's pretty clear. And yes you need to call it after RS232_CreatePort so you can pass it a port ID.

If anyone needs to modify, or get any additional properties, let me know and il make the appropriate functions.

-Andrew

Edited by andbna, 14 January 2008 - 11:23 PM.

  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#8 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 15 January 2008 - 09:24 PM

.

Edited by FlipSide, 16 October 2009 - 01:46 AM.

  • 0

#9 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 16 January 2008 - 09:14 PM

The previous version wasn't able to communicate with my RS232 microcontroller. Lets see if this one works!

<{POST_SNAPBACK}>


So, is this version able to communicate with your RS232 microcontroller?

<{POST_SNAPBACK}>

No.
  • 0

#10 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 17 January 2008 - 01:00 AM

Robot Freak, would you like me to help you try and get it working?

And il add the flow control by friday.

-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#11 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 17 January 2008 - 09:40 PM

That would be great, I'm trying to send to/receive from the Javelin Stamp, see www.parallax.com
  • 0

#12 Robot Freak

Robot Freak

    GMC Member

  • New Member
  • 271 posts

Posted 18 January 2008 - 10:38 AM

When I open the GM6 example, I get:
ERROR in
action number 1
of Create Event
for object COM1:

Error defining an external function.
For every external_define in the startup script...
The GM7 example says 'Error creating COM5'.
Maybe the DLL is defined wrong?

Edited by Robot Freak, 18 January 2008 - 10:40 AM.

  • 0

#13 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 19 January 2008 - 03:58 AM

Ok, I have added a SetFlowControl function, and updated the DLL, let me know if it doesn't work Turbe.

RobotFreak:
Make sure you extract the .gm6 and the DLL into the same folder before you open the .gm6.

The GM7 error would mean that it could not find the COM port, post or PM me what arguments you used, and make sure you can find the appropriate port in your device manager.

-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#14 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 21 January 2008 - 05:11 PM

.

Edited by FlipSide, 16 October 2009 - 01:48 AM.

  • 0

#15 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 21 January 2008 - 05:59 PM

.

Edited by FlipSide, 16 October 2009 - 01:48 AM.

  • 0

#16 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 21 January 2008 - 10:38 PM

To remove all flow controll, while most arguments are 0/false, fTXContinueOnXoff should be true;

RS232_SetFlowControl(0,0,0,1,0,0,0,0,0,0,0,0,1)

Specifies No Flow Control.

For software flow control using Xon/Xoff characters,
You need to set XonLim and XoffLim values.

XonLim and XoffLim are used to prevent the input buffer from overflowing. I believe the help file is wrong here, I will ammend it... looking at the MSDN page, it contradicts itself, those were taken directly from one of it's pages, here are correct descriptions from another of its pages:

"XonLim
Specifies the maximum number of bytes allowed in the queue.

The XON character is sent if the number of bytes in the queue falls below this number."

"XoffLim
Specifies the maximum number of bytes accepted in the input buffer before the XOFF character is sent.

The maximum number of bytes accepted is calculated by subtracting this value from the size, in bytes, of the input buffer." This one should be non-zero.

XoffLim specifies how full you want to let the input buffer get before requesting that the periphrial stop transmitting. So if our input buffer can handle 500bytes maximum, and I want to leave 100bytes in it just in case it needs to send a few extra bytes of data when I ask it to stop, I set XoffLim to 100. Setting it to 0 would resault in a buffer overflow if it got filled and the device decided to send an extra byte allong.
How much room you want to leave really depends on the application and device.

XonLim is similar, except you specify how empty you want the buffer to get before you start transmitting again.

Example:

Assuming the input buffer is 500bytes, Xofflim is 100, and XonLim is 10:

Device transmits untill the input buffer has 400bytes (500-(XoffLim=100) =400) when it's told to stop, but maby it needs to send 5 extra bytes to finish up the data its transmiting.
Input buffer contains 405bytes, now your application begins reading data from the buffer, and brings it down to 20bytes still left in the buffer, then has to process the data. The XonLim has not been reached so the device still is holding back transmiting data. The application collects more information from the buffer and brings it down to 9bytes before deciding to process the data. Since XonLim is 10, and 9 is less than 10, the device is told it can start transmitting again.
Repeat ad nauseum.

With that example, the flow control function call would look like this:
RS232_SetFlowControl(0,0,0,0,1,1,0,0,10,100,17,19,
1)

To use the RTS/CTS flow control only (which is 1-way; it assumes the computer is always ready to recieve input)

Set fOutxCtsFlow to true, and fRtsControl to non-zero (1 will mean the line is always high, 3 means it's high while there is data to be sent, and 2 is a handshaking methode. 3 is probably preffered.)
I'm Not sure if the XonLim and XoffLim actualy need values for this; I can't see why they would be relevent, but you can test.
The RTS line will let your device know when theres data ready to be sent, and the CTS line will tell the computer whether it should send or not.

RS232_SetFlowControl(1,0,0,1,0,0,0,3,0,0,0,0,1) //Assuming the XonLim and XoffLim is irrelevent

Finaly, I'l look into a function to check which ports are available.
-Andrew
  • 2
GMBullet- Take advantage of the powerful Bullet Physics library.

#17 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 22 January 2008 - 02:31 AM

.

Edited by FlipSide, 16 October 2009 - 01:48 AM.

  • 0

#18 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 04 February 2008 - 05:01 PM

.

Edited by FlipSide, 16 October 2009 - 01:49 AM.

  • 0

#19 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 04 February 2008 - 09:10 PM

The extension's included in the ZIP, in the GM7 folder.

And the available ports will have to wait, it doesn't look like Windows has standard API for it, and I have an ancient civilization to create :)

-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#20 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 05 February 2008 - 02:38 AM

.

Edited by FlipSide, 16 October 2009 - 01:49 AM.

  • 0

#21 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 10 February 2008 - 01:59 AM

.

Edited by FlipSide, 16 October 2009 - 01:49 AM.

  • 0

#22 oakwhiz

oakwhiz

    GMC Member

  • New Member
  • 268 posts

Posted 10 March 2008 - 04:43 AM

what about COM5? does it work with that?
  • 0

#23 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 30 March 2008 - 01:26 AM

.

Edited by FlipSide, 16 October 2009 - 01:50 AM.

  • 0

#24 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 30 March 2008 - 04:40 AM

what about COM5? does it work with that?

It should work with any COM or Parrallel port listed under Serial devices in the device manager.

Not sure if I found a bug or not... I have a need to change the ReadTimeout (I want to try 5ms, 10ms, 15ms and more) because I am receiving the confirmation back all the time until I do another Com Read (which I don't want to do). Flow Control is None and I am using the extension with GM7 (of course)...

I tried: RS232_SetTimeouts(10,10,1); - Locked up

By the bolded statement, do you mean the device is constantly transmitting data? If so, that could explain it. Looking at my source code, that timeout is for the interval between data, so it resets the time each time a byte is sent (thus a device sending data every 5 ms, would reset the count every 5ms, which for 10ms count means it never returns.)
Obviously, this means setting it to 0 will never return. So yes, there is a bug. I'm going to expand the function to include the total timeout (which was what I originaly intended to use), as well as the interval and multipliers for the timeouts (originaly excluded for simplicity.)

Just to confirm, -1 is like setting it to 0ms (since setting it to 0 makes it wait for ever)....

That's correct.

The DLL has been updated at time of posting.

-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#25 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 30 March 2008 - 03:32 PM

.

Edited by FlipSide, 16 October 2009 - 01:50 AM.

  • 0

#26 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 30 March 2008 - 06:34 PM

Yes the extension has been updated too.

If you solely want to use a total timeout, the first argument should be 0, since you don't care about the time inbetween recieving data. Next, set the total timeout to the time you want, in this case, 5 or 10. Finally, the multiplier can be ignored, set it to 0, since your are not concerned with ow many bytes you want to read. Thus either:
RS232_SetTimeouts(0,5,0,10,1, 1);
RS232_SetTimeouts(0,10,0,10,1, 1);

I added the other arguments for the sake of flexibility. And yes the multiplier adjusts for the number of bytes.

Also: updated the examples so their SetTimeouts calls have the appropriate number of arguments. Also, I did not build the GM6 DLL correctly last night, fixed it. Finally, found a bug in ReadString which would have rendered the multiplier timeout useless, fixed that too.

-Andrew

Edited by andbna, 30 March 2008 - 06:39 PM.

  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#27 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 30 March 2008 - 06:42 PM

.

Edited by FlipSide, 16 October 2009 - 01:50 AM.

  • 0

#28 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 31 March 2008 - 12:35 AM

I still don't understand what the first argument is used for and why it is needed... can you explain further please...?

i.e. What do you mean inbetween receiving data? ..... the 2nd (and 3rd) argument is/are handling the time the DLL waits when using a READ from something to return other than NULL.


Ok, the read function only returns on 2 conditions. A, the number of bytes requested have been read. B, the function times out.
Windows stores bytes recieved in a buffer for you to get them with the read function when you can. However, if you ask to read 100 bytes, and the buffer only has 95, the read function will not return. It will block, waiting for the device to send more. Thus, while waiting for the 100bytes you asked for, there may be multiple times in which the device sends data. eg:

0->ReadString(100,1)
->Buffer has 95 bytes
->ReadString waits for 5 more to be sent
1->Device sends 2 bytes
->ReadString continues waiting for 3bytes
2->Device sends 5 bytes
->ReadString returns 100 bytes, and 2 bytes are stored in the buffer for the next read call.

The read total timeout and multiplier start counting at event 0, and return when the time has been reached (if it had been reached at 1, ReadString would have returned then.)
A read interval time out starts counting at0, and gets reset at 1. If the time between 0 and 1, or 1 and 2 had been greater than the set interval timeout, the function would have returned before the respective event had been reached. Thus, the interval timeout gets reset each time the device sends some data while the read function is in progress.

-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#29 FlipSide

FlipSide

    GMC Member

  • New Member
  • 281 posts

Posted 19 April 2008 - 09:39 PM

.

Edited by FlipSide, 16 October 2009 - 01:51 AM.

  • 0

#30 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 23 April 2008 - 02:18 AM

Alright, I'l see if I can add that. I don't have time right away though, perhaps on the weekend.
And of course, beginning the string with a $ as a requirement would be silly.

-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#31 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 18 June 2008 - 08:42 PM

Not to bump up a 2-month-ld topic, but I have some questions.

I'm working on creating my own device connected to a parallel port, and I'm trying to use this DLL to control data to the device.

I have it wired thus: Pin 1 (strobe) is connected to pin 10 (acknowledgement). Pins 18-25 are shorted (grounds). Pins 1 & 2 (output pins for data 1 & 2) are connected to both ends of a simple DC motor.

In the GM program, I initialize the DLL and open a port to LPT1 (the parallel port). This works and returns 1. Now I try to write the byte 10000000 (using a simple binary-to-decimal conversion script) to send data only to one end of the motor to move it one direction, and I send 01000000 to send it to the other end (motor should spin the other way).

Here's the problem I'm having: When I try to write any data to the port, the game freezes, and the motor does nothing. The game ignores the Timeout (which I set to 1 with multiplier 1, so it should unfreeze immediately) and freezes completely.

Any idea what I'm doing wrong here? Does the devide need to send input back after getting output or something?

-IMP :) ::lmao::
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#32 3dcoder

3dcoder

    GMC Member

  • New Member
  • 278 posts

Posted 09 July 2008 - 02:07 PM

Thank you once again for this excellent DLL. I made a little SMS messaging server so I can now send & receive SMS-messages using web applications or GM-made programs. If anyone is interested in that, I can release it open source...

It seems to freeze sometimes when initializing the COM port, but that's kinda rare and not a major issue - and I think it's my IRDA-hardware causing that.
  • 0

#33 FantiX

FantiX

    GMC Member

  • GMC Member
  • 175 posts

Posted 21 September 2008 - 06:18 PM

nice, now i can program my microcontroller, controlling a 9 channel trafficlight (made disco from it)
:blink:
  • 0

#34 RabbidMickeyMouse

RabbidMickeyMouse

    GMC Member

  • New Member
  • 241 posts

Posted 18 January 2009 - 02:07 PM

You'll have to forgive the fact that I don't know much about serial communication, but I have a few questions.

I bought an arduino microcontroller recently, and I've known that it has the ability for serial communication. However, given my computer lacks a serial or parallel port, as well as most computers, I bought the USB model. Yet, I have the suspicion that it'll still be able to communicate serial messages with the PC.

This is the guide that describes how the arduino is hooked up to the PC:
http://arduino.cc/en/Guide/Windows

This is the reference page on serial functions:
http://arduino.cc/en/Serial/Begin

Edit: Here's a simple tutorial for serial.
http://www.ladyada.n...no/lesson4.html

If there's anything else you'd like to see concerning the arduino's serial communication, I can help find it.

I don't know much of the difference between USB and RS232. Is this beyond the scope of your DLL, even though I suspect that the communication to the arduino is serial when its programed?

Edited by RabbidMickeyMouse, 18 January 2009 - 03:24 PM.

  • 0

#35 Marchal_Mig12

Marchal_Mig12

    The Rhouan

  • GMC Member
  • 1182 posts
  • Version:GM:Studio

Posted 22 January 2009 - 05:32 PM

It looks like udp for me... Can anyone tell me what exactly it does? Does it support internet connections?

Mig
  • 0

#36 andbna

andbna

    GMC Member

  • GMC Member
  • 323 posts

Posted 23 January 2009 - 02:20 AM

I don't know much of the difference between USB and RS232. Is this beyond the scope of your DLL, even though I suspect that the communication to the arduino is serial when its programed?

As long as the device registers as a COM port under the Device Manager, you can use this DLL to interface with it. Judging by the screen shots you linked to, it does, and in the example given you would open "COM5".
So just plug it in, and check what name it registered under (COM1, COM2, etc...)

It looks like udp for me... Can anyone tell me what exactly it does? Does it support internet connections?

No, it has nothing to do with the internet. It allows you to communicate using an RS232 serial connection. Google it, you should recognize a picture of the connector.

-Andrew
  • 0
GMBullet- Take advantage of the powerful Bullet Physics library.

#37 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 25 January 2009 - 04:05 PM

I am not seeing how you could use GM to program a robot, whether you get it to connect to the microcontroller or not, unless your robot is running on a pc-like motherboard with 32bit processor and windows installed on it, and then you need to have more dlls to deal with the analog input sensors and what not. Unless you write all of this yourself, and know what you are doing -to the max- then its really not going to work. However, if you are planning on using GM to create a sort of FTP over serial to transfer hex files and the what not, then I don't see anything crazy about that :D
  • 0
My Creations:


#38 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 15 June 2009 - 10:16 PM

So you are the person who made this dll, I used this in a project.
Do you want credit?
  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#39 light

light

    GMC Member

  • New Member
  • 1 posts

Posted 29 June 2009 - 04:35 PM

Hey,
I'have a a Arduino Duemilanove too. But it won't work. I can't recieve the messages form the arduino. Witch COM port do I most choise? Can anyone help me if you can connect the arduino to the DLL and Gamemaker. Or help everybody by writing a tutorial on http://www.arduino.c...ingWithSoftware.

Thanks,
light,
lemio.nl
  • 0

#40 RabbidMickeyMouse

RabbidMickeyMouse

    GMC Member

  • New Member
  • 241 posts

Posted 04 July 2009 - 01:51 PM

I'have a a Arduino Duemilanove too. But it won't work. I can't recieve the messages form the arduino. Witch COM port do I most choise? Can anyone help me if you can connect the arduino to the DLL and Gamemaker. Or help everybody by writing a tutorial on http://www.arduino.c...ingWithSoftware.

I successfully ran my arduino with serial communication code so that GM with this DLL could read what was going on with the arduino. The code works, but is slow, and I have to work more on it to get GM and the arduino synced better (will have to later today or tomorrow).

Here's the gmk and pde I used for what I accomplished. It's simple for now (and slow as I said), but I hope to get back into working with on this again:

http://www.filedropp...rduinogamemaker

edit: Remember to set the COM in the gmk port to whatever you use in the arduino sdk to upload code

Edited by RabbidMickeyMouse, 04 July 2009 - 01:52 PM.

  • 0

#41 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 04 July 2009 - 03:47 PM

You'll have to forgive the fact that I don't know much about serial communication, but I have a few questions.

I bought an arduino microcontroller recently, and I've known that it has the ability for serial communication. However, given my computer lacks a serial or parallel port, as well as most computers, I bought the USB model. Yet, I have the suspicion that it'll still be able to communicate serial messages with the PC.

This is the guide that describes how the arduino is hooked up to the PC:
http://arduino.cc/en/Guide/Windows

This is the reference page on serial functions:
http://arduino.cc/en/Serial/Begin

Edit: Here's a simple tutorial for serial.
http://www.ladyada.n...no/lesson4.html

If there's anything else you'd like to see concerning the arduino's serial communication, I can help find it.

I don't know much of the difference between USB and RS232. Is this beyond the scope of your DLL, even though I suspect that the communication to the arduino is serial when its programed?

The arduino has a chip that creates a virtual serial port to communicate to the arduino.
There is a massive difference between USB and Serial, USB is all digital, Encoded Signals, Serial is not, Its like saying you don't know the difference between a steam powered car, and a solar car :)
I'm getting myself An Arduino Duemilanove, It would be pretty neat if i could get Gm to communicate with my arduino :D

Edited by Recreate, 04 July 2009 - 03:51 PM.

  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#42 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 21 September 2009 - 10:54 PM

Got myself the arduino, And i almost got it to communicate with my PC, Can someone post a mirror of http://www.filedropp...rduinogamemaker that the guy above my put?
It is blocked on (the current network i am connected to), Its a long story...
  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#43 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 329 posts
  • Version:Unknown

Posted 27 September 2009 - 02:49 AM

Does anyone have the original rs232 dll? I'm having problems with this one
  • 0

#44 FantiX

FantiX

    GMC Member

  • GMC Member
  • 175 posts

Posted 12 November 2009 - 05:06 PM

i need USB support. my device does not register as a com port, but as USB port.
  • 0

#45 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 329 posts
  • Version:Unknown

Posted 14 November 2009 - 01:15 AM

i need USB support. my device does not register as a com port, but as USB port.


Your USB should be registered as a COM port. Check your Device manager in Your control panel for the COM number.
  • 0

#46 FantiX

FantiX

    GMC Member

  • GMC Member
  • 175 posts

Posted 19 November 2009 - 11:44 AM

i need USB support. my device does not register as a com port, but as USB port.


Your USB should be registered as a COM port. Check your Device manager in Your control panel for the COM number.



Yes you´re right! last time i tried, a program was already using the USB device, thats why this dll failed to connect though.
  • 0

#47 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 329 posts
  • Version:Unknown

Posted 20 January 2010 - 08:42 AM

I'm thinking about getting an arduino myself. I thought of a less efficient way of connecting arduino and gamemaker. If arduino can read text files of some sort then you can have gm write arduino commands in a text file then have the arduino program interpret the code and send it to the arduion board. its not direct but it would get the job don.
  • 0

#48 zmaj

zmaj

    GMC Member

  • GMC Member
  • 327 posts
  • Version:Unknown

Posted 27 January 2010 - 06:11 PM

I think microcontroller's send's binary data as output... how to read and send that???
I have problems too...
When microcontroller sends data GM receive something, but I can't see what...
Also, when I try to send something to microcontroller , they only blink twice, and that is all...
Same microcontroller work fine with other programs...
Can someone help with this?
  • 0

zmmaj

Leader of ZmajSoft team at

http://www.zmajsoft.com

I-Goo creator and author at

http://i-goo.tk


#49 zmaj

zmaj

    GMC Member

  • GMC Member
  • 327 posts
  • Version:Unknown

Posted 29 January 2010 - 07:18 AM

I think microcontroller's send's binary data as output... how to read and send that???
I have problems too...
When microcontroller sends data GM receive something, but I can't see what...
Also, when I try to send something to microcontroller , they only blink twice, and that is all...
Same microcontroller work fine with other programs...
Can someone help with this?

I was been a stupid...
Yes there are a byte's and they are unreadable.. but... ( I was talk about microcontrollers... ) :(
Look these...

CREATE SECTION

if(RS232_CreatePort("COM1",1)!=1) //Try and open Com port 1 with ID 1
{
show_message("Error creating COM1");
game_end();
}
RS232_SetPortProperties(9600,8, 0,1,1)// these settings are setting of microcontroller... 9600= baudrate, 8 bytes are length of the message, etc...
RS232_SetTimeouts(-1,0,0,10,1,1); //Set the read/write timeouts to a typical value
str='poruka: ';
fajl= file_text_open_append('log.txt'); // all put in txt readable file
//***********END OF CREATE SECTION****************************************


STEP EVENT **************************************************
*
str=real(RS232_ReadByte(1)); //Try and read up to 1 character ( byte) form Com1

if real(str)!=-2 {
//if real(str)>64 or real(str)<90 or real(str)=32{ // more another filter for readable characters look the ASCII table for more
slovo=dekoder(str)
file_text_write_string(fajl,string(slovo))
file_text_writeln(fajl);
//}
}
//************************* END OF STEP EVENT *****************************


// DRAW EVENT **********************************
draw_text(20,20,string(str)) // just to see what was happend
// **************** END OF DRAW EVENT ****************


// How to write to microcontroler....
// PRESS <SPACE> EVENT ********************************
RS232_WriteByte(48,1); // write number 0 on the Com Port 1 ( ASCII )
// END OF PRESS <SPACE> EVENT *****************************

// SCRIPT DEKODER *************************************
// Change byte to readable characters for more look the ASCII table...
slovo='';
switch(argument0){
case 32: slovo=' '; break;// space
case 48: slovo='0'; break;
case 49: slovo='1'; break;
case 50: slovo='2'; break;
case 51: slovo='3'; break;
case 52: slovo='4'; break;
case 53: slovo='5'; break;
case 54: slovo='6'; break;
case 55: slovo='7'; break;
case 56: slovo='8'; break;
case 57: slovo='9'; break;

case 65: slovo='A'; break;
case 66: slovo='B'; break;
case 67: slovo='C'; break;
case 68: slovo='D'; break;
case 69: slovo='E'; break;
case 70: slovo='F'; break;
case 71: slovo='G'; break;
case 72: slovo='H'; break;
case 73: slovo='I'; break;
case 74: slovo='J'; break;
case 75: slovo='K'; break;
case 76: slovo='L'; break;
case 77: slovo='M'; break;
case 78: slovo='N'; break;
case 79: slovo='O'; break;
case 80: slovo='P'; break;
case 81: slovo='Q'; break;
case 82: slovo='R'; break;
case 83: slovo='S'; break;
case 84: slovo='T'; break;
case 85: slovo='U'; break;
case 86: slovo='V'; break;
case 87: slovo='W'; break;
case 88: slovo='X'; break;
case 89: slovo='Y'; break;
case 90: slovo='Z'; break;
default: break;
}
return slovo;

// END OF SCRIPT DEKODER ******************************************

// GAME END EVENT ****************************
file_text_close(fajl);
RS232_ClosePort(1)
// END OF GAME END EVENT **********************************

And this metod work....
I was try this metod on the PIC 16F877A microcontroller.... with display and with huge posibilities... :)
tnx for your time.. :lol:

Edited by zmaj, 29 January 2010 - 07:40 AM.

  • 0

zmmaj

Leader of ZmajSoft team at

http://www.zmajsoft.com

I-Goo creator and author at

http://i-goo.tk


#50 deformed thought

deformed thought

    GMC Member

  • GMC Member
  • 133 posts
  • Version:GM7

Posted 30 January 2010 - 05:44 PM

It would be nice if you could please tell me what Rs232 is used for ::lmao::
  • 0