Jump to content
43oh

Recommended Posts

I hate having to ask for help - but I'm stumped so here I am cap in hand...!

 

I've spent the best part of 4 days googling, testing, coding, etc. to try to get the example code provided in this post 29 working - posting data to Sparkfun's new simple IoT data collection site: data.sparkfun.com.  I've now gone back to the original code as I thought I may have modified more than I should have!

 

Originally the code worked, and posted to the ste correcty.  Then it just stopped connecting... to anything.

 

I then setup a quick Python socket server listening on port 50009 - and tested it using telnet.  Still no success.

 

From the original example code I have:

- modified the source & dest IP, gateway and dest port

- added breakpoints to look at getSn_SR(s)

 

In the below code, the getSn_SR(s) returns:

- 0x13 (SOCK_INIT) after the openSocket, which I'd expect

- 0x00 after the connect call, which I didn't expect

void startClient(u_char s, u_char *destinationIP, u_char port) {
    volatile u_char connResult;

    // make sure socket is closed
    waitUntilSocketClosed(s);
    // open socket on arbitrary port
    openSocketOnPort(s, 0);
    connResult = getSn_SR(s);    // ****RETURNS 0x13****
    // connect
    connect(s, destinationIP, port);
    connResult = getSn_SR(s);    // ****RETURNS 0x00****

    // verify connection was established
    // TODO add timer/counter to prevent endless loop when connection cannot be established
    while (!isConnected(s))
        ;
}

Can anyone give me any guidance to troubleshoot the connect function?  WOuld be most grateful.

 

Thanks

Andrew

Link to post
Share on other sites
  • Replies 91
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Buy: The 43oh Store or Rob's Tindie Store.   The newest version of the Ethernet BoosterPack is based on the newest chip from WIZnet, W5500.   P1.5 - SCLK P1.6 - MISO P1.7 - MOSI P2.3 - /CS P2.

Ok, my totally reworked version of RobG's G2553 example.   A number of changes have occurred here to Rob's core code: 1. Some minor bugs in the Sn_IMR macros in w5500.h were fixed (although I don't

Not yet. W5500 is different from W5200 in many ways and it requires new code. I will post something next week.

Posted Images

@@aretallack, you need to add new line after each line and two after last one.

addStringToBuffer((const u_char*) "GET /contact/ HTTP/1.1");
addStringToBuffer(sNEW_LINE);
addStringToBuffer((const u_char*) "Host: www.crash-bang.com");
addStringToBuffer(sNEW_LINE);
addStringToBuffer((const u_char*) "Connection: close");
addStringToBuffer(sNEW_LINE);
addStringToBuffer(sNEW_LINE);
flushBuffer();
Link to post
Share on other sites

Thanks @RogG - that'll help! 

 

Sorry, I've gone and amended the post from under you - bad etiquette I guess!

 

The issue I'm facing now is establishing a connection.

 

Incidentally, I'm able to runAsServer and all works perfectly, soI'm comfortable the board is working ok.

Link to post
Share on other sites
  • 4 weeks later...

Hello, 

 

Im new to the forum and I must say this is one of the more fun projects to play with. Thank you for all the work on the code!!

 

I am having an issue with the DHCP lib, i keep getting the following error:

 

dhcp read option: insufficient bytes (1) to read a DHCP option field

 

I am a noob and trying to understand how this all works.

 

Any help or ideas or things to look at is helpful!

 

Thanks

Link to post
Share on other sites
  • 3 weeks later...
  • 1 month later...

Buy: The 43oh Store or Rob's Tindie Store.

 

The newest version of the Ethernet BoosterPack is based on the newest chip from WIZnet, W5500.

 

P1.5 - SCLK

P1.6 - MISO

P1.7 - MOSI

P2.3 - /CS

P2.4 - /INT

P2.5 - /RST

 

attachicon.gifphoto-2.jpg

 

Configuration jumpers are on the bottom, PMODE1-PMODE3, LINK LED, and ACT LED.

LED jumpers control which LEDs are used, on board or socket.

attachicon.gifebp3-j2.jpgattachicon.gifebp3-j1.jpg

 

 

Available on Tindie.

Do you know what headers could be added to the PM0-PM2 so that they could be temporarily jumpered for debugging? Do you have any other suggestions? 

Link to post
Share on other sites
  • 1 year later...

Hello @@RobG

 

This thread is pretty old now and I notice that your BoosterPack has been retired, but I have recently started doing some experiments with the W5500 and G2553.  Question:  Is the latest code that was developed for your BoosterPack in the link that @@spirilis provided above?  Are there open issues you are aware of?  I plan on sharing anything I come up with.

 

EDIT:  For example I noticed that you used the MSP430F5172 in your RGB controller and wondered if memory was a problem.

Link to post
Share on other sites

Hello @@RobG

 

This thread is pretty old now and I notice that your BoosterPack has been retired, but I have recently started doing some experiments with the W5500 and G2553.  Question:  Is the latest code that was developed for your BoosterPack in the link that @@spirilis provided above?  Are there open issues you are aware of?  I plan on sharing anything I come up with.

 

EDIT:  For example I noticed that you used the MSP430F5172 in your RGB controller and wondered if memory was a problem.

Fwiw, I bet the MSP430G2955 would be perfect for Wiznet work.  56K flash, 4KB SRAM.... much more comfortable.

 

Just for kicks, this is the kind of BS I had to do to get DHCP working on a G2553, and it still leaves little room for error (probability of stack overflowing into the heap):

int dhcp_loop_configure(uint8_t *dnsaddr, struct DHCPrenew *lease)
{
        uint8_t scratch[34];
...

int dhcp_send_packet(uint8_t sockfd, uint8_t *scratch, uint8_t dhcp_msgtype)
{
        uint8_t *ourmac = scratch+SOFF_SIADDR_ACK;  // Overloading SIADDR_ACK + optcode + optlen to hold the MAC address
        uint8_t *yiaddr = scratch+SOFF_YIADDR;
        uint8_t *siaddr = scratch+SOFF_SIADDR;

...

// Read initial DHCP information
int dhcp_read_header(uint8_t sockfd, uint8_t *scratch, uint8_t *ciaddr, uint8_t *yiaddr, uint8_t *siaddr, uint8_t *giaddr, uint8_t *chaddr)
{
        uint8_t *xid = scratch+SOFF_XID;


Basically the primary function dhcp_loop_configure includes a stack-allocated scratch buffer 34 bytes long, and passes it to subjugate functions where it might reuse some of the bytes or abuse them in kind.  There was some tetris dancing involved where I had to assume (and analyze to validate it's safe) that certain scratch array positions would be reusable across different function calls based on the overall flow and sequence of the protocol.

Link to post
Share on other sites

@@spirilis

 

Thanks for the explanation.  Clever.  I haven't given up on the G2553 quite yet, but will look at the MSP430G2953 - probably make my life easier.

G2955 specifically... 5th generation of value line (note the 5 at the end).  The 4th and 5th gen Value Line chips almost "quietly" appeared a couple years ago in TSSOP & QFN-only packages, but they are relatively easy to solder if you're comfortable with SMD work (TI's "DA" package, used by the MSP430F5172 too, is a 38-pin TSSOP package in 0.65mm aka 25-mil pitch)

 

Peripherals on the G2xx4/G2xx5 work very similarly to the G2553, they use USCI for comms and BCS for clocking but the newer ones do have a Timer_B in addition to their Timer_A peripherals.

Link to post
Share on other sites

I had some time to work on this again this evening.  Using a F5529 cleared things up and I was able to get DHCP to work.

 

 

G2955 specifically... 5th generation of value line (note the 5 at the end).  The 4th and 5th gen Value Line chips almost "quietly" appeared a couple years ago in TSSOP & QFN-only packages, but they are relatively easy to solder if you're comfortable with SMD work (TI's "DA" package, used by the MSP430F5172 too, is a 38-pin TSSOP package in 0.65mm aka 25-mil pitch)

I haven't soldered SMD by hand but now that I am getting comfortable designing PCBs I am ready to try.

 

Peripherals on the G2xx4/G2xx5 work very similarly to the G2553, they use USCI for comms and BCS for clocking but the newer ones do have a Timer_B in addition to their Timer_A peripherals.

I definitely would like to give these a try. 

Link to post
Share on other sites
  • 2 weeks later...

@@spirilis

 

Thanks for your suggestion to look at the MSP430G2955, it has worked out well.

 

I ordered a few G2955s TSSOP and successfully did my first SMD hand soldering.  I have decided to use Energia, and lightly modified / cleaned up the code at the WIZnet site so that it installs and runs as an Energia library more easily.  Tested on G2955 and F5529 with Energia v17.  For those interested the code is here.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...