AWS for Industries
Helping Accelerate AUTOSAR development for Software Defined Vehicles with HAQM Q Developer
The automotive industry is undergoing a transformative shift as vehicles evolve from purely mechanical systems into sophisticated computing platforms. At the heart of this evolution are software-defined vehicles (SDVs), where software capabilities increasingly drive innovation and differentiation in the industry. Modern vehicles now contain up to 100 million lines of code across multiple electronic control units (ECUs), managing everything from safety systems to driver assistance and infotainment features.
Managing hardware and software relationships in automotive systems is challenging, especially when ensuring safety, security, and conformity with industry standards like AUTOSAR (AUTomotive Open System ARchitecture). AUTOSAR serves as the foundation for standardizing automotive embedded software, providing a comprehensive framework that encompasses software architecture, communication protocols, and development methodologies. By adhering to AUTOSAR standards, automakers can help ensure their systems maintain interoperability and scalability while meeting rigorous functional safety requirements.
To help address these challenges, HAQM Q Developer offers a specialized AI-powered coding companion that integrates with popular integrated development environments (IDEs) and the HAQM Web Services, Inc. (AWS) Management Console. It can help automotive software developers by generating and explaining code snippets, providing contextual documentation, offering code suggestions, helping with code refactoring and optimization, assisting in debugging and troubleshooting, and supporting various programming languages including C, C++, and Python. Customers have reported efficiency improvements of 25% faster initial development and up to a 40% increase in developer productivity.
This blog will demonstrate practical examples of how automotive software developers can use HAQM Q Developer to help generate AUTOSAR classic code in C/C++. Additionally, it will explore how to use Python to help streamline the creation of extensible markup language (XML) models that define AUTOSAR software components, showing you how to accelerate your automotive software development workflow while maintaining industry standards.
Prerequisites:
To follow the demonstrations discussed in this blog within your own IDE, ensure that you:
- Install the HAQM Q Developer plugin for your preferred IDE by following the installation guide; and
- Set up the Python and C programming environments on your personal computer.
**HAQM Q Developer is available to customers without an AWS account and falls within the free tier. Customers who are interested in upgrading their HAQM Q Developer license can learn more here.
It is important to note that HAQM Q Developer code generation does not guarantee conformity with any user-defined standard, and developers should check and validate code generated. Additionally, due to the non-deterministic nature of generative AI, HAQM Q Developer may produce different results from those shown in the examples below. Please also recognize that the code examples below are not for production purposes.
Accelerating AUTOSAR classic software development—Solution Overview
To demonstrate how HAQM Q Developer can assist developers, we will walk through three simple examples:
- Use Case 1 – Making an LED blink and generating unit tests in AUTOSAR C/C++
- Use Case 2 – Sending a CAN message via an ECU in AUTOSAR C/C++
- Use Case 3 – Defining package components in AUTOSAR Python
These examples demonstrate common, yet beginner-friendly, use cases of AUTOSAR development. While simplified for learning purposes, they directly map to real-world automotive applications. For example, controlling an LED uses similar logic patterns found in production vehicle lighting systems, such as automatic headlight activation based on ambient light sensors. The CAN messaging example shows how vehicle data is transmitted, like sending speed from transmission ECU to instrument display.
Use Case 1 – Making an LED blink with test cases and generating unit tests in AUTOSAR C/C++
First, let’s demonstrate how HAQM Q Developer’s inline code completion and recommendations can help streamline AUTOSAR development of software developers by automatically generating both functional code and corresponding unit tests to be reviewed by the developer. Using a basic LED blink application as our example, we’ll show how the tool can create an AUTOSAR task and generate unit tests to help verify functionality.
To begin, open the IDE where you installed the HAQM Q Developer plugin as described in the “Prerequisites” section, above. After authenticating into HAQM Q Developer, create a new C file named “examplec1.c” in your project and copy the following sample code into it. This code includes the necessary headers and LED pin configurations for our AUTOSAR-based LED blink application and will provide HAQM Q Developer context as to the type and use case of the code it should generate.
Starting Sample Code:
Now that we have our basic setup with the LED pin configuration, let’s use HAQM Q Developer to create an AUTOSAR task that will make the LED blink. In your IDE, copy the following comment on a new line under the sample code we copied into the example1.c” file in the previous step as shown below in Figure 1.
Sample Comment:
Position your cursor at the end of this comment and hit enter. HAQM Q Developer will interpret this comment and generate the appropriate AUTOSAR-compliant code for a blinking LED task.
**Please note: HAQM Q Developer is non-deterministic, meaning there’s no guarantee you will get the same recommendation as shown below**
Figure 1: Using HAQM Q Developer to help generate the blinking LED task
To accept the code recommendation, use the Tab key. With that, the file should now look similar to the below code:
Updated sample code:
Now that we have our AUTOSAR task defined, we need to create the main function that will initialize the required modules and set up the periodic execution of our LED blink task. Add the following comment to prompt HAQM Q Developer to generate the appropriate code:
Sample comment:
Similar to above, we will trigger the HAQM Q Developer inline code completion by going to the end of the comment and clicking enter.
Figure 2: Development of the main function
As shown in Figure 2, HAQM Q Developer has successfully generated the necessary AUTOSAR initialization and scheduling code for review by the developer. The main function includes StartOS() to initialize AUTOSAR, integrates with LEDBlinkTask, and configures a 500ms timer for LED blinking.
Updated Sample code:
In just minutes, using simple inline comments, we used HAQM Q Developer to help generate AUTOSAR code for an LED blinking task. This example shows how HAQM Q Developer can help accelerate automotive software development by automating tasks based on workspace context. Consider the numerous LEDs in modern SDVs—from hazard lights to dashboard indicators. Each requires specific timing and patterns, all while adhering to strict safety standards the automaker must meet. HAQM Q Developer help automakers accelerate software development by generating code, enabling rapid prototyping while reducing repetitive tasks and maintaining AUTOSAR standards.
Creating test cases
Another valuable feature of HAQM Q Developer is its ability to generate unit tests, helping the software developer ensure that the code meets required specifications and handles edge cases effectively. To demonstrate this capability, we’ll use the LED blink code we generated earlier as a basis for creating comprehensive unit tests. In this process, we will cover both the LEDBlinkTask and the main function. To leverage this feature, we’ll use the HAQM Q Developer chat functionality, which allows for more interactive and context-aware code generation. By prompting HAQM Q Developer with our existing code and specifying our testing requirements, we can quickly generate relevant unit tests that cover various scenarios and edge cases.
To use the HAQM Q Developer chat functionality, highlight the selected code we generated in the previous step and right click. From the dropdown of options select HAQM Q → Send to prompt as shown below in Figure 3.
Figure 3: Sending code to HAQM Q Developer chat
In the chat enter the following prompt and click Enter:
Figure 4: Generated test cases from HAQM Q Developer chat
HAQM Q Developer is able to generate test cases for the LedBlinkTask and for the main function. This is the updated code below for the test cases for the main function and unit tests generated by HAQM Q Developer:
Use Case 2 – ECU sending a CAN message
In this example, we’ll use HAQM Q Developer to create a voltage monitoring system, a common requirement in modern vehicles for tracking electrical component health. Specifically, we’ll generate AUTOSAR C code that periodically checks voltage on a pin and sends a controller area network (CAN) message when levels drop below a threshold. This type of functionality is commonly found in automotive systems to monitor the health of electrical components and help detect potential issues.
Open a new HAQM Q Developer chat window and enter the following prompt as shown below (another way to go about this would be using the AWS Command Line Interface (CLI)):
Figure 5: Opening a new chat window and prompting HAQM Q
Using just a simple prompt, HAQM Q Developer generates a complete AUTOSAR classic application for voltage monitoring—no sample code needed. The generated code handles everything from pin monitoring to CAN message transmission, demonstrating HAQM Q Developer’s deep understanding of AUTOSAR architecture and automotive systems. Take a look at the code structure below:
Figure 6: Generated code from the HAQM Q Developer chat
Now copy and paste the copy and paste the code into a fresh C file:
Examining the code generated by HAQM Q Developer, we see a comprehensive structure including variable definitions, a main function, and specialized functions for voltage checking and CAN message transmission. This example demonstrates how HAQM Q Developer can help automotive software developers jumpstart innovation by providing code recommendations. While this code is not production-ready and still requires developer intervention, such as unit testing, checking malformed responses, and more, it provides developers a solid starting point, helping significantly reduce initial development time and helping automotive software development teams focus on customization and optimization for their specific vehicle requirements.
Use Case 3 – Defining Package Components in AUTOSAR Python
Let’s explore our final use case: using HAQM Q Developer to help create AUTOSAR XML files using Python. These XML files are important as they define the building blocks for AUTOSAR Classic components. By starting with a simple Python script that imports the ‘os’ and ‘autosar.xml’ libraries, we’ll demonstrate how HAQM Q Developer can help automate the often-tedious process of AUTOSAR component configuration. We will be using the “AUTOSAR” repository for our sample code.
Open a new Python file in your IDE where you’ve installed HAQM Q Developer. Begin by importing the necessary Python libraries:
Starting Sample Code:
Next, using the following sample comment, we can create an entry point for our code by creating an AUTOSAR workspace and package.
Sample Comment:
Following the previous use case, copy the comment above and press enter to see the HAQM Q Developer code suggestion. Hit tab to accept the code suggestion.
Figure 7: HAQM Q completing the commented section for defining a uint8 base type
Updated Sample Code:
Now that our workspace is set up, let’s update our code to the following
With this code, we’ve created a package map for base types and implementation data types. To accelerate the rest of the functionality, we are printing the base types to allow HAQM Q Developer to learn from previous patterns in the code and autocomplete a new print statement for the implementation data types.
Figure 8: HAQM Q Developer completing the commented section for defining a uint8 base type learning from the previous code, HAQM Q Developer can help accelerate repetitive tasks and processes
Updated Sample Code:
This example, while simplified for demonstration purposes, shows how HAQM Q Developer can help automotive software developers accelerate the creation of AUTOSAR XML files in Python. Most notably, it demonstrates HAQM Q Developer’s pattern recognition capabilities, By learning from existing code, HAQM Q Developer can provide intelligent suggestions for similar operations, significantly reducing development time. While you’ll need to expand upon this foundation for production use, it illustrates how HAQM Q Developer can help streamline the often-complex process of AUTOSAR component configuration.
Clean up
HAQM Q Developer has a free tier that allows up to 50 interactions with your IDE per month. This demonstration stays below those limits but if you are interested in cleaning up what we did today follow these steps:
- Delete the files created in your preferred IDE; and
- Uninstall the HAQM Q Developer extension according to your IDE.
Conclusion
In this blog post, we explored how HAQM Q Developer can help automotive manufacturers accelerate their software development process through AI-powered code recommendations. Through practical examples, we demonstrated three key approaches: (a) using inline comments to help generate AUTOSAR code; (b) using HAQM Q chat to create comprehensive unit tests; and (c) defining AUTOSAR package components in Python. While these examples showcase HAQM Q Developer’s powerful capabilities in reducing development time, it’s important to remember that generated code requires thorough review and customization for production environments. HAQM Q Developer serves as an intelligent assistant to help speed up development cycles and reduce repetitive coding tasks, but it’s designed to complement, not replace, expert software developer judgment and automotive industry best practices.
Learn more about HAQM Q Developer today at the HAQM Q Developer getting started page, or contact your AWS team today.