1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** USBX Component                                                        */
17 /**                                                                       */
18 /**   Pictbridge Application                                              */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /* Include necessary system files.  */
25 
26 #define UX_SOURCE_CODE
27 
28 #include "ux_api.h"
29 #include "ux_pictbridge.h"
30 #include "ux_host_class_pima.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _ux_pictbridge_dpshost_output_object_get_device_status              */
38 /*                                                        PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    Chaoqiong Xiao, Microsoft Corporation                               */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This function creates the tag lines of the get_capability request   */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    pictbridge                            Pictbridge instance           */
51 /*    pima_object_buffer                    Pointer to object buffer      */
52 /*    object_length                         Length of the object          */
53 /*    pima_object_buffer_updated            Updated Address of the object */
54 /*    object_length_updated                 Updated length                */
55 /*                                                                        */
56 /*                                                                        */
57 /*  OUTPUT                                                                */
58 /*                                                                        */
59 /*    Completion Status                                                   */
60 /*                                                                        */
61 /*  CALLS                                                                 */
62 /*                                                                        */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    _ux_pictbridge_dpshost_object_get                                   */
67 /*                                                                        */
68 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
73 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*                                                                        */
76 /**************************************************************************/
_ux_pictbridge_dpshost_output_object_get_device_status(UX_PICTBRIDGE * pictbridge,UCHAR * pima_object_buffer,ULONG object_length,UCHAR ** pima_object_buffer_updated,ULONG * object_length_updated)77 UINT _ux_pictbridge_dpshost_output_object_get_device_status(UX_PICTBRIDGE *pictbridge,
78                                                  UCHAR *pima_object_buffer,
79                                                  ULONG object_length,
80                                                  UCHAR **pima_object_buffer_updated,
81                                                  ULONG *object_length_updated)
82 {
83 
84 UINT                    status;
85 
86 
87     /* Add the line <getDeviceStatus>  */
88     status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_getdevicestatus,
89                                                 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_LF,
90                                                 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
91     if (status != UX_SUCCESS)
92         return(status);
93 
94     /* Add the line <dpsPrintserviceStatus> xxxxxxxx </dpsPrintserviceStatus> */
95     status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_dpsprintservicestatus,
96                                             UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_HEXA,
97                                             UX_NULL, 0, (VOID *)(ALIGN_TYPE) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_dpsprintservicestatus, &pima_object_buffer, &object_length);
98     if (status != UX_SUCCESS)
99         return(status);
100 
101     /* Add the line <jobEndReason> xxxxxxxx </jobEndReason> */
102     status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_jobendreason,
103                                             UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_HEXA,
104                                             UX_NULL, 0, (VOID *)(ALIGN_TYPE) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_jobendreason, &pima_object_buffer, &object_length);
105     if (status != UX_SUCCESS)
106         return(status);
107 
108     /* Add the line <errorStatus> xxxxxxxx </errorStatus> */
109     status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_errorstatus,
110                                             UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_HEXA,
111                                             UX_NULL, 0, (VOID *)(ALIGN_TYPE) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_errorstatus, &pima_object_buffer, &object_length);
112     if (status != UX_SUCCESS)
113         return(status);
114 
115     /* Add the line <errorReason> xxxxxxxx </errorReason> */
116     status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_errorreason,
117                                             UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_HEXA,
118                                             UX_NULL, 0, (VOID *)(ALIGN_TYPE) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_errorreason, &pima_object_buffer, &object_length);
119     if (status != UX_SUCCESS)
120         return(status);
121 
122     /* Add the line <disconnectEnable> xxxxxxxx </disconnectEnable> */
123     status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_disconnectenable,
124                                             UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_HEXA,
125                                             UX_NULL, 0, (VOID *)(ALIGN_TYPE) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_disconnectenable, &pima_object_buffer, &object_length);
126     if (status != UX_SUCCESS)
127         return(status);
128 
129     /* Add the line <capabilityChanged> xxxxxxxx </capabilityChanged> */
130     status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_capabilitychanged,
131                                             UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_HEXA,
132                                             UX_NULL, 0, (VOID *)(ALIGN_TYPE) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_capabilitychanged, &pima_object_buffer, &object_length);
133     if (status != UX_SUCCESS)
134         return(status);
135 
136     /* Add the line <newJobOK> xxxxxxxx </newJobOK> */
137     status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_newjobok,
138                                             UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_HEXA,
139                                             UX_NULL, 0, (VOID *)(ALIGN_TYPE) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_newjobok, &pima_object_buffer, &object_length);
140     if (status != UX_SUCCESS)
141         return(status);
142 
143     /* Add the line </getDeviceStatus>  */
144     status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_getdevicestatus,
145                                                 UX_PICTBRIDGE_TAG_FLAG_END,
146                                                 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
147     if (status != UX_SUCCESS)
148         return(status);
149 
150     /* Update the caller's object position.  */
151     *pima_object_buffer_updated = pima_object_buffer;
152 
153     /* Update the caller's object length .  */
154     *object_length_updated = object_length;
155 
156     /* Return completion status.  */
157     return(UX_SUCCESS);
158 }
159 
160