Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Problem using RS232 for Communication (not deploying)


Best Answer smokingfish, 13 March 2013 - 08:50 PM

Just wanted to post the final result:

It works =D

 

It was quite a trip (as it was my first go using stuff like this) :)

You will need to build your own firmware image (and as i learned you should use MDK or RVDS, GCC and yagarto work  too but the image is too big and you will get problems with your code size and memory maps).

 

MDK5 works quite perfect, but you need a new entry to the targets file!

 

Microsoft.Spot.system.mdk.targets    <CC      Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinarmcc.exe"</CC>    <CPP     Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinarmcc.exe"</CPP>    <AS      Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinarmasm.exe"</AS>    <LINK    Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinarmlink.exe"</LINK>    <AR      Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinarmar.exe"</AR>    <FROMELF Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinfromelf.exe"</FROMELF>

You will also need to change the scatter file for MDK to

        <Set Name="Code_BaseAddress"    Value="0x0010A000"/>        <Set Name="Deploy_BaseAddress"  Value="0x00158000"/>

Im pretty sure that is not a very beautiful solution, but it works:

SecretLabs_NETMF_Diagnostics_SecretLabs_NETMF_Diagnostics_Transport.cpp

Add:

	case TRANSPORT_NONE:	    DeploymentTransport_Set(COM_SOCKET_DBG);	    break;

to:

void Transport::TransportInterface_Set( UINT8 param0, HRESULT &hr )

It changes the Interface to ETH1 wich is not available on the mini, now you can use:

Transport.SetInterface(TransportInterface.None);

in your program, the device resets and GetInterface results in TransportInterface.None!

Also, no more data is being send/received and you can use the port freely. If you want to save time add a function to your program to change it back!  

Go to the full post


  • Please log in to reply
6 replies to this topic

#1 smokingfish

smokingfish

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 10 March 2013 - 04:21 PM

Hello there,

 

I want to use the RS232 to receive data from my PC and other RS232 enabled devices.

I use a simple USB-RS232 Adapter and connected the corresponding Pins.

I also deploy over RS232 and that works just fine, so I think Adapter and Connection is fine.

 

The Idea is to use the UART for a serial Touchscreen Display and the RS232 to connect scales or other devices with a RS232 and save the MAX323.

 

I wrote a simple Serial Monitor Application wich listens to the Port. I can open it just fine, connect from PC but it does not receive any data. It works just fine with Netduino2's UART's and Netduino Mini's UART when using a FTDI cable.

 

Hope someone can help :)

 

PS: Sending from COM2 (RS232) works fine, even while using COM1 (UART) for the display I receive some of the data if I send quite a lot from the PC at once. Current idea is: As i seem to only loose incoming data, is something in the firmware polling for data (maybe for deployment?)

If yes, is there any way to use both ports at once?



#2 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 11 March 2013 - 06:58 AM

Hello there,

 

If yes, is there any way to use both ports at once?

You can use both ports for serial data.  If memory serves you have to be a little canny about how the application starts in order to ensure you can easily deploy to the Mini.

 

The application will need to manage the switch between deployment and application data being transmitted over the RS232 port.  Once you have switched the Mini into receiving serial data you will not be able to deploy again.  You need to find a way of switching back to deployment mode in order to deploy a new version of your application.  Alternatively, reflash the board in order to deploy.  

 

Two strategies for you here - use an interrupt pin to signal to the application that it should switch the port mode for deployment and then stop.  

 

Alternatively, have the application switch to deployment mode for say 5s when it first starts.  If deployment starts then it will kill the application.  If it does not then the app can carry on fine.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#3 smokingfish

smokingfish

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 11 March 2013 - 11:05 AM

Hello Nevyn,

 

yes, that is exactly what I want to do.

But how do I actually do it?

As in, is there a special function to call? A Pin to configure?

Is it enough to just open the COM Port? (it seems it isnt, because i cant receive data and deploy still works).

 

Not being able to deploy is a minor issue because I can always set 5v to DTR to go update the program.



#4 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 11 March 2013 - 12:03 PM

yes, that is exactly what I want to do.

But how do I actually do it?

There is a transport selector application in this thread.  That should give you some clues on how to select the transport provider for deploying.  I'd have a look through the class to see if there is a way of turning off the interface used.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#5 smokingfish

smokingfish

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 11 March 2013 - 02:01 PM

Thank you so much, that should be it!

I have no way of testing for now (work) but it should be as easy as this:

 

Transport.SetInterface(TransportInterface.None);

 

I will enable it on start, wait 5 seconds and then disable it, then test if the DTR 5v option still works.

If it does i will just disable it.



#6 smokingfish

smokingfish

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 11 March 2013 - 08:26 PM

Well ...OK i tried :)

I didnt work ... neither None or Usb1 , they cant be used.

I tried opening the debug port too and change then but no luck.

 

Also tried changing to Com1 but then that port is not really useable.

 

Damn, i just want to disable it :(

 

EDIT: Also, changing between Com1 and Com2 resets the board

 

EDIT:

SecretLabs_NETMF_Diagnostics_SecretLabs_NETMF_Diagnostics_Transport.cpp

it does not seem to be implemented...i might have to try to recompile the firmware and add it myself :( (no idea if the hardware would even allow it)



#7 smokingfish

smokingfish

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 13 March 2013 - 08:50 PM   Best Answer

Just wanted to post the final result:

It works =D

 

It was quite a trip (as it was my first go using stuff like this) :)

You will need to build your own firmware image (and as i learned you should use MDK or RVDS, GCC and yagarto work  too but the image is too big and you will get problems with your code size and memory maps).

 

MDK5 works quite perfect, but you need a new entry to the targets file!

 

Microsoft.Spot.system.mdk.targets    <CC      Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinarmcc.exe"</CC>    <CPP     Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinarmcc.exe"</CPP>    <AS      Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinarmasm.exe"</AS>    <LINK    Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinarmlink.exe"</LINK>    <AR      Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinarmar.exe"</AR>    <FROMELF Condition="'$(COMPILER_TOOL_VERSION)'=='MDK5'">"$(MDK_TOOL_PATH)ARMCCbinfromelf.exe"</FROMELF>

You will also need to change the scatter file for MDK to

        <Set Name="Code_BaseAddress"    Value="0x0010A000"/>        <Set Name="Deploy_BaseAddress"  Value="0x00158000"/>

Im pretty sure that is not a very beautiful solution, but it works:

SecretLabs_NETMF_Diagnostics_SecretLabs_NETMF_Diagnostics_Transport.cpp

Add:

	case TRANSPORT_NONE:	    DeploymentTransport_Set(COM_SOCKET_DBG);	    break;

to:

void Transport::TransportInterface_Set( UINT8 param0, HRESULT &hr )

It changes the Interface to ETH1 wich is not available on the mini, now you can use:

Transport.SetInterface(TransportInterface.None);

in your program, the device resets and GetInterface results in TransportInterface.None!

Also, no more data is being send/received and you can use the port freely. If you want to save time add a function to your program to change it back!  






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.