SA Driver’s Licence FAQ

With several different posts detailing some of the intracacies of the South African Driver’s Licence system, a number of questions get repeated. This post aims to address some of the most common questions.

Frequently Asked Questions:

I have an A, B, EB, C, EC, C1, EC1, Code 8, Code 10, code 14 licence, can I drive a motorbike, truck, articulated vehicle, quantum etc.

South Africa no longer has Code 8, 10 or 14 licences. In 1998 they were changed to the A, B, C, E format. You can see a comparison of before and after equivalents here. You can see what all the modern licence codes allow you to drive here.

I was arrested, charged, plead guilty to, arrested 2, 3, 5 years ago, can I get a PrDP?

You are unlikely to be approved for a PrDP if you were convicted, or plead guilty to any criminal offence in the last 5 years. That includes signing an admission of guilt. Usually this does not include ‘minor’ traffic offences such as parking or speeding tickets, assuming you were not convicted for reckless or negligent driving. If you were just arrested, or charged, but never actually convicted, you should be able to get a PrDP.

I am driving a bakkie, quantum, van, ford f150, truck do I need a PrDP?

It depends. If it’s a commercial vehicle, yes. If it has seats for more than 11 people, yes. If you are transporting people as part of your work, yes. Still not sure, read this article.

I have a code B, EB, C1, EC etc licence, and I want to get a code A, EC1 licence, etc do I have to redo my learners?

Yes. Regardless of what licence you hold, if you want to get a new licence of any code, you need to do a new learner’s licence for that code.

I am 18, 20, 25 years old, can I get a PrDP?

The minimum age for a PrDP licence is 18 for a G licence, 21 for a P licence, and 25 for a D licence.

 

The source for all answers is based on the National Road Traffic Act and it’s subsequent regulations and ammendments.

TkInter crashing without error

I’ve been working on a minor python project recently, and went back to my old friend TkInter. TkInter is the standard GUI library for Python. I had used it previously in another small project, so when I wanted to quickly get a GUI going for a project, it made sense to use TkInter. There are many other GUI libraries, but TkInter is supposedly one of the quicker and easier to get going.

TkInter has a number of shortcomings. It’s clunky and not completely intuitive. But the biggest issues that I experience with it is trying to get the interface to update from an outside perspective. My specific implementation required me to update about 20 values on the GUI by reading data from a serial port.

The easiest way to implement this is to make use of the TkInter Label widget. The Label is used for displaying any kind of text. A label can be linked to a TkInter variable, so that if you update the variable, the label automatically gets updated. The difficulty is that you need an event to trigger an update of the variables.

The way to get around this is threads. Python has built in support for threads, via the Threading class. And so you create a thread, and pass it the Tk variables and update them from the thread. This allows you to continue doing other things in the GUI, and still have your thread run. Or does it.

The immediate issue is with how TkInter queues up tasks. Because the label uses Tk variables, you can only update them by calling a set method. Not just by declaring the variable equal to a value. As such this set gets added to a queue. I found that when I clicked a drop down menu (Tk.OptionMenu), my updates would pause. My thread would effectively pause as it waited to be allowed to call the variable set method.

This was not the end of the world, and I probably would have left it like this if I didn’t continue to have the program crash unexpectedly. It would happen often, but at different times, and only when I was interacting with another aspect of the GUI. For example, when I clicked a button or selected a menu item. The program would freeze, causing the python itself to crash, and not reporting any error.

I battled to find much info on this topic. All I’ve been able to come across is the repeating statement that “TkInter is not thread safe” and that you shouldn’t try to access TkInter widgets, except from within the main thread.

There are a couple ways around this. What I ended up using is the TkInter after method. It’s janky. But it works, and has proven reliable. Since I made the change, I have not had my app crashing any more. Now I have a global variable to store the data from serial in. I have a function within my GUI object that updates the Tk variables from the global array. It then calls itself using the after method.

The after method adds a note to TK to do something after a specific amount of time has lapsed, and appears to operate much like an interrupt, ignoring whatever else I am doing and updating on schedule. I first came across the after method as described by Furas on StackOverflow.

Below is a summary of what I was doing before, and what I am doing now.

Before:

class SerialThread(threading.Thread):
  def __init__(self, gui_object):
    threading.Thread.__init__(self)
    self.gui = gui_object

  def run(self):
    #Read serial info
    self.gui.variable1.set(SERIALDATA)

class GUI():
  def __init__(self):
    self.root = tk.Tk()

    self.variable1 = tk.StringVariable(self.root)
    label1 = tk.Label(self.root, textvariable=self.variable1)

    label1.grid(row=1,column=1)

    thread1 = SerialThread(self)
    thread1.start()

 self.root.mainloop()

if __name__ == "__main__":
  GUI();

And after:

TempVariable = "XXXX"
 
class SerialThread(threading.Thread):
  def __init__(self):
    threading.Thread.__init__(self)

  def run(self):
    global TempVariable
    #Read serial info
    TempVariable = SERIALDATA
 
class GUI():
  def __init__(self):
    self.root = tk.Tk()
 
    self.variable1 = tk.StringVariable(self.root)
    label1 = tk.Label(self.root, textvariable=self.variable1)
    label1.grid(row=1,column=1)
 
    self.updateLabels()
 
    thread1 = SerialThread()
    thread1.start()
 
    self.root.mainloop()
 
  def updateLabels(self):
    global TempVariable
    self.variable1.set(TempVariable)
    self.root.after(10,self.updateLabels)
 
if __name__ == "__main__":
  GUI();

More Particle Internet Button Projects

I posted a few months ago about the Particle Internet Button I’m playing with (link). I’ve created another 2 projects in the mean time.

Adjustable Timer

The first is an adjustable timer. The lights on the Internet Button are used to indicate 30s steps, ranging from 30s to 5min. When it turns on you specify the length of time you want to run it for by either increasing or decreasing the steps. When running the 30s that are currently active flashes. At the end of the time, the Internet Button beeps and flashes red. It can be easily adjusted and reset.

particle timer

Left: select length of time
Right: Timer running

I made this back in November, but actually had a problem with it that I couldn’t figure out. I had intended to post to the Particle forums for help but never got round to it. I had in the mean time uploaded the offending code to Github. I recently reinvestigated the code with the intention of this post, and found that someone else had found my code, and solved my problem, so thanks to Github user mseneshen. Working code can be found here: source

Dice

The second project was a set of dice. Playing Catan and having people complain about how there were no 3s rolled in a game gets old, so why not create a set of dice that keep track of this and tell you facts. Apps are available for this, but then the screen turns off and it becomes a hassle. So I wrote some code to mimic a set of dice.

particle dice

Left: Dice being rolled
Right: Dice have been rolled

To roll the dice you gently shake the Internet Button sideways. The code randomly generates two numbers between 1 and 6, adds them, and outputs them by lighting up the appropriate number of LEDs. To make it easier to read, LEDs are colour coded in groups of 3. The Internet Button only has 11 LEDs, so I if a 12 is rolled, the 11th LED changes colour. Because a 1 is never rolled, I could have used that LED, but it seemed less intuitive. Also, because we play Catan, if a 7 is rolled, all the lights go red.

The whole time the dice are running, a tally is kept of how many times each number is rolled. At any time you can click a button and a distribution is published to the console. I might update this later to automatically graph the data and tweet it, but haven’t tried that yet.

When I first tested the code, I was getting reproducible random numbers, so I introduced a seed from one of the analogue pins which appears to have solved that problem. Because it uses an accelerometer to trigger a throw, when it is on it’s side, gravity is enough to trigger a throw and allows me to get thousands of throws without destroying my wrists.

Some plotted results can be seen here, with actual roll percentage (bars) vs statistical roll percentage (dots).

Code is available here: source

Temperature and Altitude

I recently bought an Adafruit BMP180 that I’m trying to get running with the Internet Button. Will post details once it’s active.

New SA Traffic Laws 2017

Recently in the news there has been some talk about new intended traffic laws. According to this article they are supposed to come into effect on 11 May 2017.  The laws are:

  • Bakkie drivers may not transport children in the back.
  • Bakkie drivers may not transport more than 5 people in the back
  • Heavy goods vehicles will be speed limited by weight, and require a sticker indicating the speed

This is going to happen. It has been published in the government gazette. Further laws that they wish to implement at a later stage, but have no due date, include:

  • Practical driving re-evaluation when renewing licence
  • Re-examine K53 (update it)
  • Lowering of speed limits in certain areas.
  • Goods vehicles with GVM > 9 tons banned during peak hours.

These laws were first discussed in 2015, but similar to the laws the DoT tried to pass in 2011, have been very poorly communicated to the public, and with any luck will be reconsidered. Both the laws that are changing and the proposed ones were published in the Government Gazette of 11 May 2015. And the Justice Project South Africa submitted some excellent commentary. To what it seems was mainly deaf ears.

I wanted to find more information about these topics, so tried looking around a bit. I first went to the eNATIS website, but their news page was returning a 404 error. The Department of Transport website didn’t go to their homepage (first google result), but asked me for login details. After getting to their proper home page, I couldn’t find any info on any upcoming changes to the NRTA. I then looked through Arrive Alive’s website and couldn’t find any news, and my browser warned me that the AA’s website was untrustworthy.

Let’s look at what’s been published though. On 11 November 2016, the 24th amendment to the NRTR was published in the Government Gazette, it had some definition changes, but ultimately the important parts were that as of 6 months after the Gazette was published, the following will come into effect. paraphrased:

school children may not be conveyed in the goods compartment of a motor vehicle for reward on public roads.

No one may be conveyed in the goods compartment of a motor vehicle for reward unless complying with NTLA provisions.

The amendment also immediately specified the inclusion of the following vehicles into the category not allowed to travel more than 100kmph, paraphrased:

vehicles between 3.5 and 9 tons

So what does all this mean? Basically what I put in the first half of this article. It means the law has and is changing. It means that there quite likely will be more changes later on, but there’s no new information.

The DoT really needs to reconsider the laws it’s implementing and take into count the excellent comments they receive back from the public, specifically organisations such as the Justice Project. They also need to do a better job of publicizing changing laws, and not rely on news outlets to publish these details. Very few people read the government gazette, and even fewer can make sense of what gets published.