Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Tesla Wall Connector load sharing protocol

This site may earn commission on affiliate links.
M_VdM helpfully pointed out that TWCManagerCarAPI v2.zip has the wrong baud rate set on line 193:

Code:
baud = 9200

It should read:

Code:
baud = 9600

Unfortunately I can't delete or modify the file, but I'm attaching a corrected version. I didn't notice the 9200 setting causing major problems during testing, but looking back there is some evidence it caused messages to be lost/corrupted periodically.

Now that I have a working P1 TWC for testing on, I've discovered that setting it to 0A won't stop it from charging a fake car device! It will only stop a real Tesla from charging. I suspect this means that charge stop requires negotiation using the Tesla proprietary communication protocol. What's really bad about this is it means the countless hours of testing I did with a P2 TWC to try to stop it from charging a fake car were completely wasted!

ARRRRRGH!!!!

The only good thing here is it means there are again a ton of options that might stop a P2 TWC from charging a real car... but I have to test them with a real car plugged in, which I really don't like. *sigh*
What are you using for a fake car? Do you have an oscilloscope so you can actually see what the pilot is doing when you set 0a? Here are the states for the pilot. If 0a were causing the pilot to stay at 0v, you would get error state E, which the J1772 wikipedia article describes as "No Power". I'm pretty sure that's how EVSEs that have a timer function turn charging off.

https://en.wikipedia.org/wiki/SAE_J1772#Signaling

https://openev.freshdesk.com/support/solutions/articles/6000052074-basics-of-sae-j1772

9020779024_283cdd58f8_b.jpg
 
  • Informative
Reactions: robertvg
What are you using for a fake car? Do you have an oscilloscope so you can actually see what the pilot is doing when you set 0a? Here are the states for the pilot.

The fake car was donated to me so I don't know much about it but it's a piece of hardware. It has a display that shows what the pilot signal is set to and it remains set to 6A despite telling the TWC to use 0A. So apparently the TWC is smart enough to not send an invalid pilot value and not try to stop charging when a non-Tesla is plugged in.

Unfortunately, I've found the car disables JTAG debugging as soon as it starts charging (fake car charging doesn't disable JTAG) which is making it very difficult to find the code used to stop charging and see if that code is called in P2 firmware. I believe TWC talks to the car using the CAN protocol on the pilot line so if I knew what CAN message is sent to stop charging I think I could find the right place quickly.

Has anyone seen someone document the CAN protocol the car charge port uses? I know it's been figured out before or we wouldn't have devices like JDapter and CAN-SR for the roadster. I don't need the whole protocol - just the stop charge message.

Code:
Response: FD 1B 04 04 0D 00 00 00 00 00 00 00 00 30
This is a presumably
European gen 2 TWC , bought in April directly in a Tesla store in Austria.

That's the same firmware version as my US P2 TWCs purchased sometime before Jan 2018. Interesting.
 
I did some logging on the can bus of the TWC.

CAN id 0x30C is the one you need.
Only one byte is sent:
0x00 Stop Charging
0x01 Start Charging

Thanks Fuzzylogic! Unfortunately, there is only one reference to 0x30C in the firmware and it appears to be comparing 30C to the MsgID of a message received from the car and taking some action. So 30C might be the car telling the TWC it wants to start or stop charging, but I need the message the TWC sends the car to tell the car to stop charging. This message is sent by P1 firmware when you tell the TWC to use 0Amps using the master heartbeat in the RS485 protocol.
 
M_VdM helpfully pointed out that TWCManagerCarAPI v2.zip has the wrong baud rate set on line 193:

Code:
baud = 9200

It should read:

Code:
baud = 9600

Unfortunately I can't delete or modify the file, but I'm attaching a corrected version. I didn't notice the 9200 setting causing major problems during testing, but looking back there is some evidence it caused messages to be lost/corrupted periodically.

Now that I have a working P1 TWC for testing on, I've discovered that setting it to 0A won't stop it from charging a fake car device! It will only stop a real Tesla from charging. I suspect this means that charge stop requires negotiation using the Tesla proprietary communication protocol. What's really bad about this is it means the countless hours of testing I did with a P2 TWC to try to stop it from charging a fake car were completely wasted!

ARRRRRGH!!!!

The only good thing here is it means there are again a ton of options that might stop a P2 TWC from charging a real car... but I have to test them with a real car plugged in, which I really don't like. *sigh*
I tried the Python version with my EU TWC from somewhere in 2017 and it does not seem to work:

root@raspberrypi:~# /root/TWCManagerCarAPI/TWCManager.py
TWC Manager starting as fake Master with id 7777 and sign 77
08:44:07: Send master linkready1
08:44:07: Send master linkready1
08:44:07: Send master linkready1
08:44:07: Send master linkready1
08:44:07: Send master linkready1
08:44:07: Send master linkready2
08:44:07: Send master linkready2
08:44:07: Send master linkready2
08:44:08: Send master linkready2
08:44:08: Send master linkready2
08:44:11: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:44:21: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:44:31: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:44:31: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:44:32: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:44:33: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:44:43: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:44:53: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:45:03: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:45:03: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:45:04: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:45:05: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:45:15: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:45:25: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:45:35: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:45:35: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:45:36: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
ERROR: Checksum 221 does not match 11. Ignoring message: FD F2 82 04 1D 0C 80 00 00 00 00 00 00 00 00 11
08:45:46: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:45:56: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
08:46:06: 32.00 amp slave TWC 8204 is ready to link. Sign: 1D
ERROR: Checksum 231 does not match 11. Ignoring message: FD E2 82 04 3D 0C 80 00 00 00 00 00 00 00 00 11

That's all I'm seeing, but the TWC keeps blinking Red and thus does not charge.

I finally want to make to to work on my smarttwc Python library, but it would be easy if I could just sniff the packets TWCManager is sending, makes life easier :)
 
That's all I'm seeing, but the TWC keeps blinking Red and thus does not charge.

They errors you're showing strike me as corruption in RS485 signals. Either the wire is too long, the wire pair is not twisted together (even 6" of untwisted wire can create problems), the RS485 USB adapter is bad, the TWC RS485 terminal is bad (this actually happened on one of my TWCs - try the other pair of terminals), a terminal is not tight enough (see if a wire pulls out from any screw terminal without much force), or you need termination. I think I talk about termination options in the PDF install manual.
 
Last edited:
A bit off topic, but on the TWC firmware update: I have noticed that since two or three weeks it is now possible to unplug a TWC from a (EU) car when charging has stopped. This has changed with a recent fw update on the car but I suspect also a fw update on the TWC. I have a type 2 charging cable with a button to open the charge door/unlock the charging cable and the same trick does not work with that cable.
So there is definitely some communication between the car and the TWC so that the car knows it is on a Tesla charger.
I've been meaning to test this. I've found that the behavior is the same charging with a second gen HPWC and a J1772 w/ the adapter. I have not tested my gen 1 UMC or at a supercharger.

If the car is locked, done charging, and I approach without my key, the car will unlock the charge port on the first press of the button on the charge handle, allowing me to withdraw the HPWC or J1772 adapter. If I release the button without unplugging the car, the charge port re-locks. If I press the button again, nothing happens (you only get one try).

Since the port unlocks with every J1772 I've tried, I don't believe there is any communication with the HPWC. Since the port lock is handled by the car, no communication with the HPWC is necessary to unlock the port.

I think this is a pretty serious bug, since it allows someone to steal your J1772 adapter if they get to your car before you once it finishes charging. Without this "feature," the worst anyone could do at a public J1772 would be unplug the car while charging, but your adapter was always securely locked to the car. Not anymore!

Even if you are done charging, and someone wants to use the handle, they could accidentally unplug the J1772 adapter from the car if they aren't careful. Once the port re-locks, they can't re-install the adapter in your charge port, so you're screwed. They could leave the adapter on your roof, windshield, etc, but it won't last long there.
 
I think this is a pretty serious bug, since it allows someone to steal your J1772 adapter if they get to your car before you once it finishes charging. Without this "feature," the worst anyone could do at a public J1772 would be unplug the car while charging, but your adapter was always securely locked to the car. Not anymore!

Good points. This is a more serious bug if it happens with the ~$500 CHAdeMO adapter.

It would be best to start a new thread on this topic with a descriptive subject. Tesla might notice.
 
If the car is locked, done charging, and I approach without my key, the car will unlock the charge port on the first press of the button on the charge handle, allowing me to withdraw the HPWC or J1772 adapter. If I release the button without unplugging the car, the charge port re-locks. If I press the button again, nothing happens (you only get one try).

I believe there has always been a difference in behavior between US and EU cars wrt unlocking the charger cable.
Anyway just to let you know: the functionality seems to have been reversed in firmware 2018.21.9, it is not possible anymore to release a TWC from a locked car once the charging has stopped (verified with several cars after the update) <subject closed>
Apologies for starting this off-topic topic.
 
They errors you're showing strike me as corruption in RS485 signals. Either the wire is too long, the wire pair is not twisted together (even 6" of untwisted wire can create problems), the RS485 USB adapter is bad, the TWC RS485 terminal is bad (this actually happened on one of my TWCs - try the other pair of terminals), a terminal is not tight enough (see if a wire pulls out from any screw terminal without much force), or you need termination. I think I talk about termination options in the PDF install manual.
Probably. I didn't twist the wires very well. I'll check that.

While I'm working on the Python code I checked Github and I saw that you only have the Perl code there. Would it be possble to add the Python code as well?
 
  • Like
Reactions: M_VdM
I believe there has always been a difference in behavior between US and EU cars wrt unlocking the charger cable.
Anyway just to let you know: the functionality seems to have been reversed in firmware 2018.21.9, it is not possible anymore to release a TWC from a locked car once the charging has stopped (verified with several cars after the update) <subject closed>
Apologies for starting this off-topic topic.
Actually, I'm on 2018.21.9 and saw the behavior, so 2018.21.9 didn't fix it. I think there's something more complicated here - possibly the car has to be charged and sleeping for the charge port to unlock? I can't reproduce it today, but I signed up for TeslaFi yesterday, so that may be a factor. What I saw it last night, the car was outside of wifi and cell coverage, so it was probably able to sleep. I'll keep exploring...

@tga: Be carefull not to mix "HPWC" (old Gen I) and "TWC" (new Gen II) devices in this sort of discussions.
Before you know, people are talking about completely different hardware ...;)
Of course: all info is welcome !
Yes, although TWC is close to (if not the actual) acronym for the old Roadster 70A EVSE...
 
Yes, although TWC is close to (if not the actual) acronym for the old Roadster 70A EVSE...
That was called HPC for High Power Connector. After the S was released they changed it to HPWC for High Power Wall Connector. That was rather confusing because both the Roadster and Model S chargers had the same name. They should have left the Roadster version as it was, HPC so you could tell the difference. The acronym UMC for Universal Mobile Connector has always been the same for all versions.
 
That was called HPC for High Power Connector. After the S was released they changed it to HPWC for High Power Wall Connector. That was rather confusing because both the Roadster and Model S chargers had the same name. They should have left the Roadster version as it was, HPC so you could tell the difference. The acronym UMC for Universal Mobile Connector has always been the same for all versions.
Heh, I wasn't even close. Well, I got one letter. Nevermind. FWIW, my Gen 2 (HP)WC just says "Wall Connector" on the box and manuals.
 
I'm still stuck with getting TWCManager running. While developing the smarttwc Python library I'm testing with TWCManager, but I can't get my TWC to link.

I've replaced the cable between my Pi (It's about 1,5m) and the TWC, but this is all I keep getting:

root@raspberrypi:~# /root/TWCManagerCarAPI/TWCManager.py
TWC Manager starting as fake Master with id 7777 and sign 77
19:46:32: Send master linkready1
Tx@19:46:32: C0 FC E1 77 77 77 00 00 00 00 00 00 00 00 46 C0 p2
19:46:32: Send master linkready1
Tx@19:46:32: C0 FC E1 77 77 77 00 00 00 00 00 00 00 00 46 C0 p2
19:46:32: Send master linkready1
Tx@19:46:32: C0 FC E1 77 77 77 00 00 00 00 00 00 00 00 46 C0 p2
19:46:32: Send master linkready1
Tx@19:46:32: C0 FC E1 77 77 77 00 00 00 00 00 00 00 00 46 C0 p2
19:46:32: Send master linkready1
Tx@19:46:32: C0 FC E1 77 77 77 00 00 00 00 00 00 00 00 46 C0 p2
19:46:33: Send master linkready2
Tx@19:46:33: C0 FB E2 77 77 77 00 00 00 00 00 00 00 00 47 C0 p2
19:46:33: Send master linkready2
Tx@19:46:33: C0 FB E2 77 77 77 00 00 00 00 00 00 00 00 47 C0 p2
19:46:33: Send master linkready2
Tx@19:46:33: C0 FB E2 77 77 77 00 00 00 00 00 00 00 00 47 C0 p2
19:46:33: Send master linkready2
Tx@19:46:33: C0 FB E2 77 77 77 00 00 00 00 00 00 00 00 47 C0 p2
19:46:33: Send master linkready2
Tx@19:46:33: C0 FB E2 77 77 77 00 00 00 00 00 00 00 00 47 C0 p2
Rx@19:46:35: () FD E2 82 04 6F 0C 80 00 00 00 00 00 00 00 00 63
19:46:35: 32.00 amp slave TWC 8204 is ready to link. Sign: 6F
Tx@19:46:35: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:36: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:37: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:38: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:39: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:40: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:41: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:42: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:43: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:44: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Rx@19:46:45: (FC) FD E2 82 04 6F 0C 80 00 00 00 00 00 00 00 00 63
19:46:45: 32.00 amp slave TWC 8204 is ready to link. Sign: 6F
Tx@19:46:45: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:46: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:47: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:48: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:49: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:50: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:51: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:52: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:53: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:54: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Rx@19:46:55: (FC) FD E2 82 04 6F 0C 80 00 00 00 00 00 00 00 00 63
19:46:55: 32.00 amp slave TWC 8204 is ready to link. Sign: 6F
Tx@19:46:55: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Rx@19:46:55: (FC) FD E2 82 04 6F 0C 80 00 00 00 00 00 00 00 00 63
19:46:55: 32.00 amp slave TWC 8204 is ready to link. Sign: 6F
Tx@19:46:55: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Tx@19:46:56: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Rx@19:46:57: (FC) FD E2 82 04 6F 0C 80 00 00 00 00 00 00 00 00 63
19:46:57: 32.00 amp slave TWC 8204 is ready to link. Sign: 6F
Tx@19:46:57: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2
Rx@19:46:57: (FC) FD E2 82 04 6F 0C 80 00 00 00 00 00 00 00 00 63
19:46:57: 32.00 amp slave TWC 8204 is ready to link. Sign: 6F
Tx@19:46:57: C0 FB E0 77 77 82 04 00 00 00 00 00 00 00 00 00 54 C0 p2

The TWC keeps blinking Red and does not charge either. It just throws an error to the car.

Any ideas what it might be?
 
Messages being sent back and forth look correct but the slave is behaving like it's not seeing anything fake master is sending. This could still be a wiring problem. Try a really short twisted pair cable or add termination resistors. Also eliminate any possible electrical interference near the RS485 wire like wires running power to other devices. If you want to run RS485 from in the TWC to a Pi at some distance, use a shielded, twisted-wire cable intended for carrying signals, like an ethernet cable. Also try turning TWC off and on again, just in case.

Another possibility I mentioned earlier is your RS485 adapter is bad and sending weak or non-existent signals out. I had something like that happen with a cheap adapter from ebay (although I forget in what way it failed, exactly). If you have an oscilloscope you can see if the voltage on the wires is varying as much on Tx message as on Rx message.
 
Last edited:
That's what I figured indeed that my TWC isn't getting the messages my fake master is sending.

It's not running along any high power cables and I'm using CAT6 cabling with a small shield in there, so I think the cable is OK.

I'll see if I can find a new USB adapter and rule out that's the problem.