JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012 1981

The XM Satellite Radio Software Module of an Embedded Car Audio System

Di Wu Dalian University of Technology, Dalian, China Email: [email protected]

Chenxi Hou Dalian University of Technology, Dalian, China Email: [email protected]

Limin Sun Institute of Information Engineering, Chinese Academy of Sciences, Beijing, China Email: [email protected]

Yan Ling Dalian University of Technology, Dalian, China Email: [email protected]

Jiangchuan Liu Simon Fraser University, Vancouver, Canada Email: [email protected]

Abstract—XM radio service is an emerging satellite digital product design and manufacturing industry, digital car audio radio service suitable for automotive environment, it audio system [1] products are gradually getting into the offers users high-quality radio programs with better signal vision of more and more automobile users. The digital car coverage by adopting communication satellite broadcasting audio system products meet the visual and auditory technology. In order to incorporate XM radio function into entertainment demand of consumers for during a car ride, a digital car audio system based on the embedded system industry standard ITRON, we analyze both software and they offer brand new entertainment experience options hardware requirements of the XM function module in this for car passengers and drivers on the trip, and have work. Architectural design that separates the XM radio transformed itself into an indispensable composing part function module into five layers is given. The operating of on-board digital systems. In recent years, car system selected for the used in the car audio manufacturers are constantly launching car models by system is introduced. Implementation details of the XM advancing and adopting more effective design and function module, such as control commands and device manufacturing techniques in order to meet the of the XM tuner, the state increasingly picky taste of hypercritical automobile transition matrix layer and the application layer are also consumers. The quality of digital car audio system presented in this work. configuration has a considerable decisive impact on the Index Terms—XM radio, digital car audio system, purchasing selection of automobile consumers. The embedded system, ITRON, communication protocol, state improvement of function and quality of digital car audio transition matrix. systems is becoming ever more important for both automobile manufacturers and automobile consumers. This paper focuses on the design and implementation I. INTRODUCTION process of a function module named the XM radio module in a real development project of a digital car With the rapid development of the automobile audio system. The digital car audio is a sub-system of an manufacturing industry and rapid growth of the travel on board electronic control system, which operates within demand of consumers, the global automobile sales is a software environment provided by the embedded real- magnifying year by year. The strong demand in the time operating system compliant with industry standard automobile consumer market has prompted the ITRON [2,3]. General development techniques and the maturation and development of a series of other related application status quo of car audio systems are displayed industries, the digital car audio manufacturing industry is in this work. a typical example of these industries. As the extension of automobile manufacturing industry into electronic II. XM BROADCAST RADIO SERVICE

© 2012 ACADEMY PUBLISHER doi:10.4304/jsw.7.9.1981-1992 1982 JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012

XM is a SDARS (Satellite Digital Audio Radio Touch Panel Service) [4,5] broadcast radio service operated by the US Display company SiriusXM in North American regions including XM Radio Service the USA and Canada of. SDARS is a branch of digital Video-Audio Speaker Satellite audio broadcasting [6] services which incorporates Microcontroller multiple communication satellites for radio program broadcasting. IEBUS XM radio program signal is delivered by five of the Main DSP XM Tuner nine in-orbit satellites of the SiriusXM Company. The Microcontroller I2S radio program signal is transmitted to and then broadcast from these satellites to the ground listening devices. The Key Control Panel working band of XM radio service rests on the 2.3GHz S band, with frequency ranging from 2320MHz to 2345MHz. Figure 1. Block diagram of XM car audio system hardware XM service was launched on September 25, 2001 in related to broadcast radio functionality. the USA, providing high quality broadcast radio service that surpasses existing radio services like FM and AM on the other hand, it has several special requirements for both in sound quality and geographic coverage. In order both software and hardware configuration of the digital to maintain signal strength, in areas where signals may car audio system. The detailed hardware configuration weaken greatly, like places in the vicinity of high rise can be seen in Figure 1. buildings in downtowns and under-ground car parks A. Hardware Requirements where satellite signal might be blocked, ground receivers are installed to rebroadcast signal to guarantee constant The hardware requirements of XM broadcast radio and full coverage for subscriber usage. functionality can be separated into two classes. The first Since the XM radio service adopts a business model class includes hardware shared among many different base on paid subscription, various kinds of programs with system functions, like on which the rich content and premium sound quality are provided to operating systems run, chips that can process and adjust the users,. At present, there are over 180 stations whose audio signals, speakers that play processed audio signals types span of music, news & talk, sports, and traffic & input from the main microcontroller, display screen that whether available in the XM radio service, some displays system states, key control panels, and touch automobile owner can listen to the XM radio service with panel display. The second class includes special hardware the eight-digit identity number called Radio ID assigned specifically required by the XM broadcast radio to each on board XM tuner device for three month trial functionality, which includes external devices that can period usually provided by the automobile manufacturer. receive broadcast radio signal from the satellites and the By the end of the year 2010, the number of subscribers to data communication bus that establishes data exchange the XM radio service operated the SiriusXM company on the connection between the microcontroller and the has exceeded 20 million to 20.19 million, showing strong external device. In the development project of the digital market demand for satellite broadcast radio service, the car audio system, an XM satellite broadcast radio signal sales of digital car audio systems with preinstalled XM receiver called XM tuner is adopted to receive radio radio listening devices and corresponding software program signal from the satellites, and a data solution will benefit from this process of market demand communication bus named IEBUS is used to connect the growth dramatically. XM tuner to the microcontroller in the head unit of the digital car audio system. During the design phase of the car audio system III. REQUIREMENT ANALYSIS OF THE IMPLEMENTATION product, taking into account the conservation of OF XM BROADCAST RADIO FUNCTION manufacturing cost and differences of device control and In general, the objective of the development project is data processing demands for the whole car audio system to establish a digital car audio system that consists of in the actual environment, two microcontrollers with microcontrollers, display screen, operation panel of keys, different processing capabilities are adopted. multiple external devices and speakers. These For the special demands for user interface drawing on components provide users with a series of complete car the LCD screen and decoding processing of video media audio system functionalities that include signal content, a video audio microcontroller customized for processing, system state display, user input acquisition, graphics performance optimization is adopted. playback of media content in external connected devices The other microcontroller, namely the main and sound output to the users. XM broadcast radio is one microcontroller is responsible for power management, of the functionalities that needs to implement in the car audio signal output to DSP chips for sound output, audio development project. The integration of XM radio detection of key press on the control panel, and data may be discussed from two perspectives. On one hand, exchange with several external devices via different kinds the XM radio module relies on the common infrastructure of data communication buses. shared among other digital car audio system function The two microcontrollers are connected by 32-bit data modules like FM/AM radio, Bluetooth audio and so on, communication bus named CSI (Configurable System

© 2012 ACADEMY PUBLISHER JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012 1983

Interconnect). Via the CSI bus, the two microcontrollers IV. ARCHITECTURE OF DEVELOPMENT FOR XM can exchange data with each other according tocertain BROADCAST RADIO FUNCTION inter-microcontroller communication mechanism. The implementation of XM function is divided onto two microcontrollers. The video audio microcontroller Human Machine Interface controls human-machine interaction functions like the drawing of XM user interface on the touch panel display State and the detection and resolution of user touch input on Application Transition the touch panel when the XM radio user interfaces are Matrix active. The main controller sends control commands to the XM tuner device whenever a user key press input takes place, and takes feedback execution result of Driver control command, and passes the display data from the XM tuner device to the video audio microcontroller side to refresh the user interface accordingly. Operating System This work is mainly about the implementation of the XM tuner device driving functions. The process of controlling the XM tuner device is done entirely by the Figure 2. Layered development architecture of car audio system main microcontroller of the car audio system. based on ITRON standard. In the digital car audio system development project, a microcontroller of V850ES/SJ3 series produced by NEC TheFigure digital1. car audio system development project Company is adopted as the main controller, its highest adopts a layered architecture based on the ITRON working frequency can reach up to 32MHz. The total embeddedFigure 2. operatingNote how the system caption is standard centered in. theThis column. architecture number of general registers is 32, the data length of each includes five layers, and they are human machine register is 32bits. The data size of ROM is between interface, state transition matrix, application, driver and 384KB and 1024KB, the data size of RAM is between operating system layers from the top to the bottom, as 32KB and 60KB. V850ES/SJ3 microcontrollers has a shown in Figure 2. total of 128 I/O ports, its serial interfaces enable data communication via serial buses like UART, CSI and I2C, A. Human Machine Interface Layer besides, IEBUS and CAN bus controller are also present The human machine interface layer is at the top of the for data communication with external devices. The A/D, whole architecture, it is responsible for the interaction D/A converters of V850ES/SJ3 enable conversion between the digital car audio system and the users. Its between analogue and digital signals. The timing function responsibility includes acquiring in input from the user, is provided by five timers, including three 16-bit timers, a notifying the user of the current working state of the car watch timer and a watchdog timer. To conserve power audio system and notifying the user of the processing consumption, power-saving modes named as result of operation request of the user. The human HALT/IDLE/STOP/subclock/sub-IDLE are provided to machine interface layer takes input from the user, the users of V850ES/SJ3 microcontrollers. resolves the exact operation type, generates and passes operation request event message to the state transition B. Software Requirements matrix layer. The working state notification is mainly Software requirements of XM function can also be completed by the main display screen of the car audio separated into two classes. The first class includes system, screen text information like song name and list of software that controls fundamental hardware, like available channels is displayed to the user. The software that controls DSP chips for audio signal notification of the processing result of any operation processing, which can adjust sound output effects like request is mainly conducted by refreshing the user volume, treble, bass and so on. The first class of software interface, in some cases by sounding the beeper, for includes not only graphics-related software that draws instance, when continuous multiple key press operations user interface and manages user interface transition, but are conducted by the user in a short period of time, the also key press processing software that detects long key press processing capacity of the system may fail to press/short press, soft key press on the touch panel, deal with all these requests immediately, a beeping alarm dragging key operation and resolves pressed key type can be sounded to inform the user to prevent conducting from coordinates. Software in the second class includes a more invalid key press operations. device driver which manages and controls the working state of the XM tuner, sends control commands to and B. State Transition Matrix Layer acquires responses and device and radio program Inside the car audio system, there are many time information from the XM tuner, an IEBUS I/O driving consuming operations, each task may also receive software which enables data exchange between the main messages containing service requests while an on-going microcontroller and the XM tuner device by bus reading processing is present. Due to the real-time requirement of and writing, and a communication protocol that the car audio system, setting up request message queue to encapsulates operations of IEBUS I/O driving software. postpone the processing of an incoming request message during busy time is not allowed. To guarantee the real-

© 2012 ACADEMY PUBLISHER 1984 JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012

time character of the system, for each service request D. Driver Layer message that has arrived at the task, the system must The driver layer lies in the place nearest to the bottom decide whether an immediate processing is possible. For hardware in the architecture, it is mainly used to conceal those requests that are unable to be processed the details of the operation of digital car audio devices. immediately, a request failure notification should be The process of driving device includes the use of certain hardware control protocol and I/O communication protocol software and needs to comply with certain Multi-task Application timing requirements and data format conventions. The driver layer encapsulates device operation processes into message interfaces for upper layers to implement the Kernel Interface Library control function of devices. E. Operating System Layer Operating System Kernel The operating system layer is the foundation of the whole car audio system architecture, it is responsible for System Hardware the management of fundamental hardware and software resources, accepting resource requests from tasks, allocating and recycling shared resources and ensuring

correct and orderly use of resources. The detailed Figure 3. Layers of ITRON standard compliant embedded real-time functions of the operating system layer includes the operating system. management of task life cycle, the scheduling of task execution, synchronization and communication of tasks, replied to the sender task, otherwise, the processing is dynamic management of memory, interrupt management, performed and working state is transitioned accordingly. timer management and so on. All layers above the The differences of the event carried by the arriving operating system layer can issue system calls to request message and working state of the system can both incur service of the operating system and implement designed differences of system processing responses to the requests, functions under the support of the operating system. thus, tasks can use the state transition matrix to decide the proper response to the arriving messages during different V. ITRON STANDARD COMPLIANT EMBEDDED REAL-TIME working states. When a request message arrives from the OPERATING SYSTEM human machine interface layer, the state transition matrix needs to recognize the current working state of the task, The two microcontrollers of the digital car audio and look up in the matrix cell for the processing action system, namely the video audio microcontroller and the that should be taken and the state to transition to after the main microcontroller are responsible for certain different processing action in a matrix with row being the event of types of system functions like computing, communication, the message and column being the current working state, key press detection and device control respectively, they afterwards, the corresponding processing action is must perform these functions in orderly, effective and conducted and state is transitioned. The state transition real-time way cooperatively. The embedded real-time matrix maintains the working state of tasks to conduct operating system is a type of operating system widely proper processing action on the input message and used in embedded real-time environment. As a type of maintains the proper transition target of working state for embedded system, it has common characters of the processing of future incoming messages. embedded software like reducibility, low occupation of resources and low power consumption; while as a type of C. Application Layer real-time system, in addition to satisfying function The design purpose of application layer is to establish requirements of application, it must further satisfy the an isolation layer between the practical functions and real-time requirements of application, meaning that bottom hardware functions, hiding the impact of changes several important operation parameters measuring the of hardware beneath the human machine interface layer real-time level of a system, like system response time, and state transition matrix layer and providing a task switching time, interrupt delay time must be collection of relatively stable application interfaces for controlled within the range permitted by the users. upper layer design. Only single functions are ITRON (Industrial the Real-Time Operation System implemented in the application layer interface, the actual Nucleus) is a real-time multi-task operating system implementation of a single application interface may standard. ITRON has a standard real-time kernel and is contain call requests to multiple functions of the driver applicable for any small scale embedded system. ITRON layer underneath according to certain timing and logic has become an important industrial standard in embedded requirements. The design of using application layer hides device industry and has been widely adopted by digital implementation details of lower layer to the upper layers car audio system development projects. The main and improves the stability and portability of the system. microcontroller in the car audio system development project adopts Rx850 operating system, which complies with ITRON v4.0 standard.

© 2012 ACADEMY PUBLISHER JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012 1985

The architecture of ITRON can be divided into four mail receiving function rcv_msg. When tasks need to layers, as shown in Figure 3. The lowest layer is the send mail message to other tasks, they can fill parameters system hardware layer, including ROM, RAM, into corresponding fields of mail variables, including the microprocessor, timer, I/O controllers and so on. Above target mailbox, the identifier of the current task, the event the hardware layer is the operating system kernel, which code which identifies the type of the mail message and is written completely in assembly code. The kernel is the mail option field. After parameters are properly set, a designed to provide fundamental system functions like function call to the mail sending function snd_msg can task management, synchronization and communication, complete the mail sending process. interrupt management, memory management, timer Intensive use of inter task message communication management, system scheduling and so on. The kernel mechanism can be found in the car audio system interface library provides system service in the form of development project, tasks cooperate with each other external functions, system calls issued in the form of frequently so as to implement system functions. external functions can thus invoke service programs within the operating system kernel. The multi-task VI. LAYERED IMPLEMENTATION OF THE DRIVING application layer represents tasks responsible for the FUNCTION OF XM TUNER DEVICE implementation of application level functions, which is dependent on project development. The most important A. Control Commands of XM Tuner Device part that needs to be implemented in the project The XM tuner device is the special device for development phase is the design of the main functions of receiving XM radio signals, its antenna can receive tasks. The main function of a task acquires notifications program data from the XM service satellites, and the in- or service requests from other tasks and sends built memory can save user setting data. The IEBUS notifications or service requests to other tasks to interface can be used for receiving control commands implement the system function which it is responsible for. from the microcontroller inside the head unit of the  Task Priority and Task Scheduling of ITRON. digital car audio system, and command response and Tasks of ITRON acquire opportunity of execution display data can be sent back to the microcontroller. under the scheduling of the operating system. In the Upon receiving control commands from the startup configuration file, different priorities of execution microcontroller, the XM tuner device can change are set for different system functions according to their parameters of XM signal reception and the working state real-time level requirements. When multiple tasks are in of the XM tuner device. ready state in the task scheduling queue, the kernel would The control commands used in the development execute the first task with the highest priority, for tasks project can be classified into the following classes: preset with equal priorities, execution would start from the task station commands, tune mode commands, station scan that arrives first in the scheduling queue. commands, station adjustment commands, information  Task Structure and Message Communication acquisition commands and electronic diagnosis Mechanism of ITRON. commands. The execution of a task begins from the main function 1. Preset Station Commands of the task, the structure of a main function is an infinite Preset station commands are the control commands loop. At the beginning of the infinite loop, mail message associated with preset station list display functions. The is received from the associate mailbox of the task. preset station list is a list of stations saved inside the non- Afterwards, the task can judge from the event code and volatile memory of the XM tuner device, the items in the source task data fields of the mail about what notification station list are added by users during the listening period. or service request is sent and which task the sending task The capacity of the preset is limited in the development is, and then acquires data from the option field of the mail project, the XM tuner device can accommodate a certain message required by the execution of the service request number of stations within the internal memory. The user or the processing of the notification. Thus, task may enter may either choose an item added before in the preset into a specific execution or processing period after the station list to start playing or save the present active reception of the mail message. After the reception and playing station into an item in the preset station list processing of a mail message, the task execution would specified by the user. When the display screen switches go back to the beginning of the infinite loop and wait for into the user interface where the preset station list is the next incoming mail message. present due to some user operation, the digital car audio Within the ITRON standard, inter-task message system must also send request to the XM tuner for the communication mechanism is established primarily by complete content of the preset station list. The four preset the mail sending function snd_msg, the mail receiving station commands can be seen below. function rcv_msg, the mailbox system object and mail  Preset Station Call data structure. The mailbox system object is set up in the  Preset Station Write system startup configuration file and will be initiated  Preset Station List along with the initialization of the system. Every task that  Preset Station Immediate Write needs to communicate with other tasks in the system is 2. Tune Mode Commands associated with a mailbox system object. Tasks may The tune mode is a state flag that decides whether the receive mail message from associated mailbox by the command execution to be the range of all channels or the

© 2012 ACADEMY PUBLISHER 1986 JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012

range of only channels within the current category for Category Up and Category Down commands would cause some user commands. the XM tuner device to switch the current listening The XM tuner device doesn’t maintain such a state flag station to the last station in the previous or the next by itself, however, all commands related to the tune mode category to receive radio program signals. Direct Tune are subject to the tune mode. The microcontroller has to command is triggered by the user operation of directly keep a record of the tune mode in order to map operation clicking an item within the channel list for listening, this requests to the commands that should really be sent to the command carries a station number which the XM tuner XM tuner device. The tune mode has two values, device can switch to and start receiving radio program corresponding to the two different modes: channel mode signals. Here is a list of the channel adjustment and category mode. The execution range will be set up as commands. either for all currently available channels or for channels  Channel Mode Channel Up/Down only within the current category at the time of the  Category Mode Channel Up/Down operation request. There are two tune mode commands:  Channel Rough Up/Down the Tune Mode Switching command can switch tune  Category Up/Down mode between the two available modes; the Tune Mode  Direct Tune Information command can query the microcontroller for 5. Information Acquisition Commands the current tune mode. The information acquisition commands are the  Tune Mode Switching commands that are used to acquire desired information  Tune Mode Information from the XM tuner device. Normally, when the 3. Station Scan Commands transitions in the user interface take place, the The station scan commands are the control commands microcontrollers need to send these commands to the XM to perform station scan actions on the available channels. tuner device to acquire the information required by the The station scan action is a process in which each user interface. available channel within the execution range specified by Active Channel Information command is used to the current tune mode is played for 10 seconds acquire the text or number information related to the sequentially for one round in the direction in which current listening station, information types include the station number increases. station number, the channel name, the category number, The tune mode makes difference to the execution of the category name, the program title, the artist name. the station scan request. When the tune mode is channel Channel List Information and Preset Channel List mode, the stations to be scanned are all available Information commands are used to acquire the list of all channels at present, otherwise, when the tune mode is available channels and the list of all items of the preset category mode, the execution of the station scan action list within the internal memory from the XM tuner device, would be confined to all available stations within the respectively. Radio ID Information command is used to present category. The two station scan commands are as acquire the radio identity number information of an XM follows. tuner device, this information is displayed when the  Channel Mode Scan current listening station is set to the 0th station. The  Category Mode Scan Radio ID is a unique identity number assigned to each 4. Channel Adjustment Commands XM tuner device used for subscription to the XM The channel adjustment commands are the control broadcast radio service. The information acquisition commands that are related to the adjustment of the commands are listed below. current listening station. Channel Mode Channel Up and  Active Channel Info Channel Mode Channel Down commands are sent to the  Channel List Information XM tuner device when the tune mode is channel mode,  Preset Channel List Information upon receiving these commands, the XM tuner device  Radio Id Information would switch the current listening station to the previous 6. Electronic Diagnosis Commands or the next available station to receive radio program The electronic diagnosis commands are specifically signals. Category Mode Channel Up and Category Mode used for the quality assurance process before the digital Channel Down commands are sent to the XM tuner car audio system products leave the factory. A computer device when the tune mode is category mode, upon system with quality diagnosis functions would be receiving these commands, the XM tuner device would connected to the target system, usually to an input port of switch the current listening station to the previous or the a microcontroller. Internal diagnostic commands would next station within the current category to receive radio then be sent to modules of the system under diagnosis. program signals. Channel Rough Up and Channel Rough The execution results would be sent back for the Down commands can be sent to the XM tuner device diagnostic system to judge whether functions of the target only when the tune mode is channel mode. Every time product system is working correctly. The diagnosis these commands are received, the XM tuner device would information has plenty of diagnosis items, indicating switch the current listening station to 10th available whether the product quality meets the requirements and station higher or lower than the present one to receive whether the product performances reach the factory radio program signals, these commands offer the user an standard. All electronic diagnosis commands are listed easier way to switch to the target station in big steps. below.

© 2012 ACADEMY PUBLISHER JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012 1987

 Diagnosis Mode Set upper applications, the control commands that are used to  Diagnosis QoS control the operation of the XM tuner device are  Diagnosis Change contained in the message data field as well. The control commands of the XM tuner device are B. IEBUS Command Format and Bus Communication stored in the message data field of the IEBUS data frame, Protocol Program for XM Tuner Device as shown in Figure 4. The control command data consists Control commands that are used to control the of a total of seven data fields, where TP is the type of a operation of the XM tuner device are sent to the IEBUS command, CMD is the unique number of a command communication bus by the main microcontroller in the within a command type, TL is the function address of the sending device and LN is the function address of the variable receiving device, LS and ST are the state information of 1 bit 12 bit 12 bit 8 bit 8 bit length the sending device of the microcontroller side and the Frame Physical Address Physical Address of Control Data Message device side, respectively, and CS is the checksum. Header of Sending Device Receiving Device Bit Length Data For each control command in any of the several classes IEBUS Data Frame of XM tuner device control commands, namely the preset station commands, the tune mode commands, the station TP TL LN LS ST CMD CS scan commands, the channel adjustment commands, the information acquisition commands and the electronic XM Tuner Device Command diagnosis commands, there is a definite value pair of TP and CMD. The control process of the XM tuner device can be completed by filling the corresponding values in Figure 4. Composition of IEBUS data frame and the control command of the TP and CMD field in the control command of the the XM tuner device. IEBUS data frame, setting TL and LN fields with the function addresses of the microcontroller and the XM digital car audio system head unit. The IEBUS tuner device, and writing the whole IEBUS data frame to communication bus is a communication method only for the IEBUS communication bus to send the commands to the data exchange between the microcontroller and the the XM tuner device. Upon receiving this IEBUS data XM tuner device, several other external devices in the frame, the XM tuner device would resolve the control digital car audio system development project are command from the microcontroller and perform actions connected onto the IEBUS communication bus to corresponding to the command, thus, the operation communicate with the microcontroller or other external request of the user is received and executed. devices on the IEBUS communication bus. For this In addition to the XM tuner device control commands, reason, the IEBUS communication bus needs to define display data frames that are sent back to the the format of IEBUS data frames and establish a microcontrollers are also sent via the IEBUS communication protocol to distinguish different devices communication bus. In the digital car audio system on the IEBUS communication bus, mark the total length development project, the IEBUS data frame wring and of a data frame and provide data validation mechanism reading operations on the microcontroller side are to detect transmission errors of data frames. encapsulated into the IEBUS device communication As shown in Figure 4, the IEBUS data frame contains protocol. The IEBUS device communication protocol is the frame header and five data fields, which are the implemented by IDC (IEBUS Device Controller) and IDS physical address of sending device, the physical address (IEBUS Device Sender) tasks. The IDC task is of receiving device, the control bit, the data length and responsible for the communication with upper layer the message data. The physical address fields can identify modules and the control of the IDS task to send data the sending device and the receiving device connected frames; the IDS task receives directives and parameters onto the IEBUS communication bus, the control bit field from the IDC task, forms IEBUS data frame and writes it contains control information related to the control of the to the IEBUS communication bus using the IEBUS communication process, the data length field indicates the driving program. When the IDS task tries to write the length of the message data, the message data field IEBUS data frame, a possible occupation of the IEBUS contains all the data used in the communication between communication bus by other external device may block

IEBUS Device Communication Protocol IEBUS Communication Bus Command Command Send Request Directive Command Upper Module Sent of XM Module IDC IDS Command Received Command Command Send XM Tuner Response Result Display Data Display Data Display Acquisition Data Notification

Figure 5. Data exchange of IEBUS device communication protocol.

© 2012 ACADEMY PUBLISHER 1988 JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012

the immediate completion of the data frame writing Standby and process. Hence, a maximum number of times of writing Source Matrix retries is set up in the IDS task. The writing retries continue before the retry count reaches the maximum number of retries. When the retry number limit is Source Action Diagnosis Info Acquisition exceeded, the IDS task would give up on data frame Matrix Matrix Matrix writing and send busy state report message to the IDC task. The IEBUS device communication protocol is at the Preset Station driver layer of the XM function module, as shown in Operation Matrix Figure 5, its encapsulation of IEBUS writing and reading operations offers the XM module the control command interfaces based on message communication. The XM module only need to set the event code and option fields Preset Station Preset Station Preset Station Immediate Call Matrix Write Matrix Write Matrix of the message according to requirements of the IDC task and send the message to the IDC task, and then the IEBUS device communication protocol can recognize the Figure 6. Tree hierarchy of state transition matrices of XMSTM task. message and write control commands to the IEBUS communication bus for the XM tuner device to take corresponding actions. The state transition matrix is two-dimension table, with the two dimensions being the state and the event, the cells C. State Transition Matrix Layer of XM Module of the table contains the processing action and the target There are multiple states for the XM broadcast radio transition state. The state dimension corresponds to function module during the real operation of the digital different states of the XM module, and the event car audio system. The system state can be divided into dimension corresponds to the input messages of the XM standby and normal states, the XM module can also stay module. When a message arrives at the XMSTM task, the in standby and normal states. Because the car audio XMSTM task would query the current state and look up system have multiple sound sources, like XM, FM, for the corresponding cell along with the event contained AM ,CD and others, the XM module have source on and in the message in the state transition matrix. With the source off states. The user key press operations may content of each cell, the XMSTM task executes the cause the XM tuner device to enter into long lasting processing action and alters the state of the XMSTM task action states, like station scan. During this period of to the target transition state. The completion of the state ongoing actions, the user might want to try changing the transition is also the completion of the processing of an state of the XM tuner device by key presses, and the XM input message, and then the XMSTM task will then wait module need to choose between to accept or to reject for the next input message of the XM module. such operation requests according to the current action There are a variety of events of input messages to the state of the XM tuner device. At the end of a long lasting XMSTM task, whose source task may be one of the action, the XM tuner device would send state change power manager task, the RPCAPP task, the sound task notification to the XM module, and the XM module need and the XMAPP task. The power manager task sends to adjust its state accordingly to keep its action state power management messages to notify the XM module to consistency with the XM tuner device. enter or leave standby state, the RPCAPP task sends to The existence of different states causes different the XM tuner device control requests and XM sound processing methods of external inputs for the XM module. source on/off requests, the sound task sends response Hence, the XM module needs to establish a state messages of turning on or off the sound output in the XM mechanism to guarantee appropriate processing for each tuner device control process, and the XMAPP task of the input request, response or notification message. The state XM module sends response messages to report the result transition matrix offers the XM module the method to of XM tuner device control commands. establish the state mechanism, a XMSTM task is formed The working states of the XM module are divided into in the XM module to maintain the state transition matrix several layers, forming an obvious layered hierarchy. A and process input messages. top-down layered tree hierarchy stems from the containing relationship of states. Each group of states that can be changed by the same collection of events are organized into a state transition matrix and the event collection is mapped into one single event in the upper state transition matrix, in the upper matrix cell, a call to the lower matrix would start the processing process for each event in the collection of events. Therefore, the XMSTM task can use multiple state transition matrices in the tree hierarchy for state maintenance and message processing, as shown in Figure 6.

© 2012 ACADEMY PUBLISHER JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012 1989

Standby and normal states would affect processing of code maintenance in the future would be greatly other message events, the XM source on and source off complicated. events affect message events only next to Standby and Therefore, a framework for event processing named as normal states, these four states are put on the top layer of Process Engine is introduced to perform concentrated and the XMSTM task to maintain. When the XM sound standard processing on the request and response events. source is turned on, there are normal receiving, channel 1. Implementation Principle of Process Engine scan and preset transition states for each of the two tune A Process Engine can be seen as a collection of a modes, channel mode and category mode, there is also a group of associated process tables, each process table can channel rough up/down state for the channel mode, the be called as a top-level process table, the Process Engine seven states should be maintained considering the instant uses an address table to record the starting addresses of setting of the tune mode, they can form a state transition all top-level process tables. In the Process Engine, the matrix at the second layer. Because all preset station execution of a top-level process table corresponds to the operation-related XM tuner device control commands processing of each pair of request and response events. involves the enabling and disabling of the sound output, A process table is the collection of a group of the third and fourth layer are formed for state processes, which is embodied as an array of process maintenance of the preset operations. States associated structure in the implementation program of the Process with diagnosis and information acquisition operations are Engine. The processes of a process table lie in the array only affected by the state transition matrix at the top layer, in a certain order, and each process is called a stage of a so both of them are also put on the second layer. process table, which is referenced by array index corresponding to the process in the process table. D. Application Layer of XM Module The smallest execution unit of a Process Engine is a The application layer of the XM module lies between process, the execution of a Process Engine is required to the state transition matrix layer and the driver layer, start from a specified process. Before the execution of a bridging the communication between the two layers. The Process Engine, both the starting process table and the state transition matrix layer takes processing actions starting stage or the position of the starting process of the whenever an input event arrives, for control command starting process table need to be specified when setting events, the processing actions include passing the type of the Process Engine. the control command and corresponding parameters to A process represents the execution of a series of the IEBUS device communication protocol and then drive programs, it could either be the execution of a process the XM tuner device to perform corresponding operations. table consisting of other processes or merely be the The application layer is primarily responsible for the execution of one single subroutine. The return value of conversion of message from the original form to the the execution of processes in a process table can be one format ready for the IEBUS device communication of two different return values, the control flow may jump protocol to send. into one of two branches according to the return value At this layer, API functions are defined for calls from following the execution completion, and each branch is the state transition matrix layer. API functions bound with one return value corresponding to the jump. encapsulate the process of sending control command The target of the jump may either be another process of messages to the XMAPP task of the XM module. Upon the same process table, namely the stage of the process receiving messages, the XMAPP task resolves the event table or the tail of the process table containing the type, converts the message into the required format and currently executing process, that is to say, following this sends it to the IDC task of the IEBUS device jump, the execution of the whole process table is over. To communication protocol for control command generation non-top-level process tables, the control flow goes back and writing to the IEBUS communication bus. to the execution environment of the process table which The trunk of the XMAPP task is designed into an contains the current process, and the stage of that process infinite loop, which begins by receiving an event from the table needs to jump correspondingly, similarly, two jump associated mailbox into a variable whose type is a mail branches are also present, and the jump is performed structure , subsequently the event code of the event is according to the return value that would be set following read from the variable whose type is the mail structure. the jump after the current process. The values of all event codes are divided into three At the end of process execution, the jump target setting consecutive segments, corresponding to three types of of two branches should also include information events consisting of request, response and information concerning continued or discontinued execution after the notice events. According to the requirements of XM radio process jump of the Process Engine. For continued functionality, there are several tens of kinds of request execution, the Process Engine performs the execution of and response events, each pair of request event and its the next process immediately after the process jump, corresponding response event share nearly the same while for discontinued execution, the Process Engine structure when it comes to event processing. Manual stops execution and exits after the process jump, and if no coding would generate abundant redundant code for the reset is performed on the starting process of the Process processing of the two kinds of events. This results in two Engine before the next execution of the Process Engine, consequences. On one hand, the memory occupation the execution would continue be performed right after the would dramatically increase when the whole project is previous exiting process. This feature allows the Process compiled, on the other hand, the code comprehension and

© 2012 ACADEMY PUBLISHER 1990 JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012

Engine to do the following, when the processing of a block structure variable respectively. request event is finished, a process jump with The process control table block structure contains a discontinued execution may be done so that the execution total of five comprising members, which are execution of the Process Engine may stop before the processing request setting flag, active buffer number, process engine process of the response event corresponding to the buffer pointer, process engine process table address and request event, until the response event arrives, the subroutine address table, as shown in Figure 7. execution of the Process Engine is triggered and the The execution request setting flag is a one byte processing of the response event may be completed. unsigned integral data whose effective value is either true The Process Engine uses a group of data structures and of false, represented by 1 and 0, the field is used to mark interface functions to implement the setting and execution whether the Process Engine has been requested to execute. initiation of the Process Engine, which is stated in detail Only by setting this field true before calling interface in the following. function to start the execution of Process Engine can the 2. Data Structure of Process Engine function call really start the execution of the Process The mechanism of Process Engine relies on three data Engine. Whenever the Process Engine finishes its structures to implement: process control table block execution, this field is set back to false. structure, process engine buffer element structure and The process engine buffer pointer is the pointer to process structure. The most important data structure is the process engine buffer element structure type, it points to process control table block structure, a variable defined in the memory space required by the execution of Process this type can be seen as a Process Engine. The process Engine. Two members constitutes the process engine engine buffer element structure and the process structure buffer element structure, they are process table number are used to define the members of a process control table and execution stage number. The process table number

Process Control Table Block Process Engine Execution Subroutine Active Buffer Process Engine Process Table Request Address Number Buffer Pointer Address Table Setting Flag Table Pointer

Buffer Element 1

Buffer Element 2

······ Subroutine 1 Address Buffer Element n Subroutine 2 Address ······ Process Engine Buffer Element Subroutine n Process Table Execution Stage Address Number Number

Process Table Process Address Table Table Process Table 1 Process 1 Address Process Table 2 Process 2 Address ······ ······

Process Table n Process n Address

Process Stucture

Process Table 1st Branch 1st Branch 2nd Branch 2nd Branch Index Flag Stage Number Return Value Stage Number Return Value

Figure 7. Data structure of process engine.

© 2012 ACADEMY PUBLISHER JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012 1991

references the position in the process engine process table stage return value. Both the process table flag and the address table which holds the process table containing the index are one byte unsigned integral data, the process current process, the execution stage number references table flag is used to mark whether a process represents a the position of the current process in the current process subroutine or a process table, a subroutine is specified table. Each element of the process engine buffer when the process table flag is set 0, the index is the represents a process table and its stage of execution. At position of the subroutine in the subroutine address table; the beginning of the execution of the Process Engine, the a process table is specified when the process table is set 1, first element of process engine buffer is provided for the the index is the position of the process table in the first process to be executed by the Process Engine, the process engine process table address table. The first two members of the process engine buffer element branch stage number and second stage number is the structure together specify the process table and the stage target stage number following the current executed to start from. Subsequently, with the advance of the process, they could either be the actual target stage execution of the Process Engine, the actual size process number to be executed next or one of the two special engine buffer would expand or shrink, each initialization values that indicate the finish of the current process table of the execution of a process that represents a process with 0 or 1 as return value respectively. The first branch table would cause the process engine buffer to expand by return value and second branch return value are the return one element, and the process table number of the newly values to be set for the whole process engine on the finish expanded element is the position of the process table in of every process, usually, this return value is used to the process table address table, with the stage number of return certain values concerning the timeout of message the newly expanded element being 0, the two members reception of tasks, which limits the longest waiting time together specify the first stage of the process table to be for continued execution of the process engine. the process to be executed next. If the execution comes to The subroutine address table is defined as the array of the end of the current process table, then the process function pointers of all subroutines used by the process engine buffer would shrink by one element, and the engine. Because an array is formed to facilitate the buffer element that represents the process table recently process to reference the subroutine by index, all executed would be discarded, and the Process Engine subroutines should have the same prototype, with no would go back to the next stage of the process table one arguments present and one byte integral value be returned level higher over the discarded process table to continue as return value. Subroutines that require argument input the execution. should use global variables to pass necessary input before The active buffer number is a one byte unsigned any function call. The return values of subroutines are integral value which is used to reference the element formulated into only two different values, corresponding corresponding to the current executing process in the to the two return branches on process execution process engine buffer, this element records both the completion, the two values represent whether the control process table and the corresponding stage for the current flow continues along the first branch or the second branch executing process. The process engine buffer is in fact the respectively. stack memory required by the execution of the Process 3. Interface Function of Process Engine Engine, and each element in the stack represents the The interface function of process engine is used for process table and its executing stage, the active buffer initialization setting, state query and ultimate execution number is the current stack top pointer, with the advance start of process engine. Defining a process control table of the execution of the Process Engine, the value of active block structure variable begins the use of a process buffer number increase or decrease to reflect the engine, this variable record all the setting information and expansion and shrinking of the process engine buffer, and execution environment for the whole process engine. The the process table to be executed is pushed into the stack process control table block structure variable will be used and the process table to be discarded on execution as an argument throughout all interface function to completion is popped from the stack. When one process construct and operate the process engine. is over and the next stage of the same process table is Four steps are needed to create, set and execute a going to be executed, the stage number of the process process engine, corresponding to four interface function engine buffer referenced by the active buffer number calls, process engine set interface, execution request set needs also to be modified by the Process Engine to the interface, starting process set interface and process engine stage number of the process to be executed, which is in execution interface. fact the modification of the content of the top element in The process engine set interface does initialization the stack memory for the advance of the execution. settings on the process engine, besides arguments like The process engine process table address pointer is the process control table block structure, several members pointer to the process address table, the type of each that need to be initialized externally are also included in process table address table is the array of process the arguments, the process engine buffer pointer, process structure. The process structure represents process, engine process table address table pointer and subroutine namely the smallest execution unit of the Process Engine. address table. The interface associate the externally The process structure consists of a total of six members, created resources to the process engine and clear state process table flag, index, first branch stage number, first values like execution request setting flag and active branch return value, second stage number and second buffer number back to the original state.

© 2012 ACADEMY PUBLISHER 1992 JOURNAL OF SOFTWARE, VOL. 7, NO. 9, SEPTEMBER 2012

The execution request setting interface has process ACKNOWLEDGEMENT control table block structure as its only argument. Only This work is supported by the Open Research Fund by setting the execution request flag to valid value can from the Key Laboratory for Computer Network and the process engine execution interface function call Information Integration (Southeast University, Ministry effectively start the execution of the process engine. of Education, China), the Fundamental Research Funds The starting process setting interface has arguments of for the Central Universities, the Program of National process control table block structure and the process table Natural Science of China ( Grant No. 60933011 and number of the starting process. This interface sets the 61073014), and the State Key Development Program for active buffer number to zero, set the process table number Basic Research of China (Grant No. 2011CB302902 ) of the active buffer element according to the argument value, and initialize to zero the execution stage number of REFERENCES the active buffer element. This interface makes the first stage of the specified process table the process to start [1] J. Kontro, A. Koski, J. Sjoberg, “Digital car audio system,” from of the whole process engine. IEEE Transactions on consumer electronics, vol. 39, pp. The process engine execution interface has only 514-521, August 1993. process control table block structure as its argument, [2] A. Hassan,, “RTK-spec TRON: A simulation model of an when the execution request setting flag of this structure is ITRON based RTOS kernel in SystemC,” Proceedings - Design, Automation and Test in Europe, vol. 1, pp. 554- set to valid state, the process engine is able to execute 559, 2005. according to existing settings. [3] H. Du, S. Wang, X. Sun, “Research of hybrid OS architecture based on Linux on ITRON,” Jisuanji VII. CONCLUSION Gongcheng/Computer Engineering, vol. 32, pp. 84-86, 2006. This paper shows the design ideology and [4] Mariottini, Francesco, “Design of a compact GPS and implementation method of the XM satellite broadcast SDARS integrated antenna for automotive applications,” radio function module in a software application IEEE Antennas and Wireless Propagation Letters, vol. 9, development scenario with ITRON standard compliant pp. 405-408, 2010. real-time operating system and hierarchical architecture [5] S. DiPierro, R. Akturan, R. Michalski, “Sirius XM satellite of a digital car audio system project. The XM function radio system overview and services,” 2010 5th Advanced module is installed in the Rx850 embedded operating Satellite Multimedia Systems Conference and the 11th system within the digital car audio system project after Signal Processing for Space Communications Workshop, compilation. After software defect elimination in the pp. 506-11, April 2010. [6] M. Nariman, H. Hamed, F. Mehdi, “Digital audio testing phases of unit test, integration test and system test, broadcasting system modeling and hardware the real operation results of the digital car audio system implementation,” Advanced Microsystems for Automotive suggests that the XM function module is compatible with Applications 2004, pp. 313-324, 2004. other function modules in the system, it responds to user operations correctly and timely, and it is able to drive the XM tuner device to receive and play XM broadcast radio program.

© 2012 ACADEMY PUBLISHER