Wiring Teensy4.1 to MagJack

Hi. I am having trouble finding info on now to connect a SparkFun MagJack Breakout to Teensy 4.1 ( The magjack schematic did not help.) But by comparing to other schemes I came up with this. I ran a UDP server program previously working with an Uno, changed the library of course, but it’s not working. I can see there is activity at the magjack , Teensy is receiving incoming data, the led is flashing and I can serial.print it, but the response is not making it back to the client… I don’t think this is a software thing because this program had been working fine before I ported to Teensy. Maybe I’m using the wrong pins or maybe its my soldering? Can anyone comment on the connection? BTW No connections to P4 P5 and Led to Led. BTW - Core - could you please supply an ethernet kit for the Teensy 4.1?

Update. I am getting one way connection. I had a bad solder joint on my earth which has been attended to. I have tested with a udp server, which had been tested on an UNO and ported over to the Teensy 4.1. The server waits till it a receives a message from a client and then responds. The problem is there is no response. It is receiving the incoming message and appears to send a reply but nothing is going out on the wire. I suspect it is a hardware problem, perhaps a faulty Teensy?.

I am using a python client program running on a pc to send messages,. The two are connected over a single direct ethernet cable with a fixed IP address. I should mention that I tried pinging the server and it pinged back - which surprised me. Is there a logical explanation for this kind of behaviour? I also used wireshark to confirm that no message is being sent by the server… Code can be provided if necessary.

1 Like

Hey Gerald,

Very interesting, this sounds like it may be some kind of an error with the scripts and how they’re interacting if you’re successfully able to ping the host and it responds accordingly. Can you please send through your code we can take a look through?

Bryce
Core Electronics | Support

1 Like

Hi. Thanks for replying. I have been experimenting and it is looking like a code problem. The weird thing was that I hadn’t changed my original Uno code. It seems to be related to how I am preparing the text strings I’m sending. It’s all very easy when they are short, but longer strings which I have to concatenate seem to cause problems, particularly over 24 characters for some reason… I was also thrown by the fact it didn’t seem to cause any kind of error when it failed to send, it just did so very quietly. Also I’m finding that loading code to the Teensy is a bit erratic. Sometimes it seems to get stuck or jdoesn’t update. I will post some code when I’m more certain what does and doesn’t work…

1 Like

Hey Gerald,

That’s very interesting, so do you still have errors at exactly 24 characters? Also, can you try using it with another datatype to see whether the same issues occur? I’m wondering whether we’re exceeding some type of fixed maximum by using Strings in particular, which seems quite unusual. Also, that can occur sometimes with the Teensy in particular, which IDE are you using to flash your code?

Bryce
Core Electronics | Support

What library are you using for ethernet on the teensy?

Perhaps the pjrc forum may be useful. Like this thread

Hi Robin / Bryce. As far as I know there is only one libary for ethernet on Teensy 4.1. It is called “native ethernet”. I started with the example program “UDPSendReceiveString”. My first problem was with the length of the received string. If was being truncated to 24 chars. But I managed to overcome that by changing two lines.

char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);

Logically we might assume that these could handle anything up to whatever the max size is. But not so. I changed the MAX_SIZE values to an int value 512 - big enough to handle expected incoming packets.

Sending out I also had some problems, which was why I thought I had a hardware problem, but that turned out to be more about how the data is prepared using string concatentation etc. Strings in Arduino are still very confusing to me… :frowning: For that it seems the pjrc site might be more the place to look?

Meantime - I’ll repeat my comment. If I’d had a proper ethernet adapter at the start, I would have twigged to the software issues earlier, rather than spend much time investigating and messing with the wiring my homemade adapter. I hope Core do eventually include that as an option when buying the board… :slight_smile:

1 Like

Hey Gerald,

I agree, the PJRC site would likely have info on that. If you’d like to send us your best suggestion for a part to support@coreelectronics.com.au and I can get that through to purchasing to see what we can do for other customers in the future. Have a great day!

Bryce
Core Electronics | Support

1 Like