1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Pictbridge Application */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_pictbridge.h"
#include "ux_device_class_pima.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_pictbridge_dpsclient_object_data_send PORTABLE C */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function accepts the data of the object. */
/* */
/* INPUT */
/* */
/* pima Pima instance associated */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* */
/* CALLED BY */
/* */
/* user application */
/* */
/**************************************************************************/
UINT _ux_pictbridge_dpsclient_object_data_send(UX_SLAVE_CLASS_PIMA *pima, ULONG object_handle,
ULONG phase,
UCHAR *object_buffer,
ULONG object_offset,
ULONG object_length)
{
UINT status;
UX_PICTBRIDGE *pictbridge;
UX_SLAVE_CLASS_PIMA_OBJECT *object_info;
ULONG event_flag = 0;
UCHAR *pima_object_buffer;
/* Get the pointer to the Pictbridge instance. */
pictbridge = (UX_PICTBRIDGE *)pima -> ux_device_class_pima_application;
/* Get the pointer to the pima object. */
object_info = (UX_SLAVE_CLASS_PIMA_OBJECT *) pictbridge -> ux_pictbridge_object_host;
/* Is this the correct handle ? */
if (object_info -> ux_device_class_pima_object_handle_id == object_handle)
{
/* Get the pointer to the object buffer. */
pima_object_buffer = object_info -> ux_device_class_pima_object_buffer;
/* Check the phase. We should wait for the object to be completed and the response sent back
before parsing the object. */
if (phase == UX_DEVICE_CLASS_PIMA_OBJECT_TRANSFER_PHASE_ACTIVE)
{
/* Check if it will fit in our buffer. */
if (object_offset + object_length > UX_PICTBRIDGE_MAX_PIMA_OBJECT_BUFFER)
return(UX_MEMORY_INSUFFICIENT);
/* Copy the demanded object data portion. */
_ux_utility_memory_copy(pima_object_buffer + object_offset, object_buffer, object_length); /* Use case of memcpy is verified. */
/* Save the length of this object. */
object_info -> ux_device_class_pima_object_length = object_length;
/* We are not done yet. */
return(UX_SUCCESS);
}
/* We now have the entire script into memory. Parse the object and execute the script. */
status = _ux_pictbridge_object_parse(pictbridge, pima_object_buffer,
object_info -> ux_device_class_pima_object_compressed_size);
/* Analyze the status from the parsing and determine the result code to be sent back. */
switch (status)
{
case UX_SUCCESS :
/* Set the result code to OK. */
pictbridge -> ux_pictbridge_operation_result = UX_PICTBRIDGE_ACTION_RESULT_OK;
break;
case UX_PICTBRIDGE_ERROR_SCRIPT_SYNTAX_ERROR :
/* Set the result code to Error. */
pictbridge -> ux_pictbridge_operation_result = UX_PICTBRIDGE_ACTION_RESULT_NOT_SUPPORTED_IP;
break;
case UX_PICTBRIDGE_ERROR_PARAMETER_UNKNOWN :
/* Set the result code to Error. */
pictbridge -> ux_pictbridge_operation_result = UX_PICTBRIDGE_ACTION_RESULT_NOT_SUPPORTED_UP;
break;
case UX_PICTBRIDGE_ERROR_PARAMETER_MISSING :
/* Set the result code to Error. */
pictbridge -> ux_pictbridge_operation_result = UX_PICTBRIDGE_ACTION_RESULT_NOT_SUPPORTED_MP;
break;
default :
/* Set the result code to Error. */
pictbridge -> ux_pictbridge_operation_result = UX_PICTBRIDGE_ACTION_RESULT_NOT_SUPPORTED_DEFAULT;
break;
}
/* We may have a complete event. We only raise the event flag if the completion was successful. */
if (pictbridge -> ux_pictbridge_operation_result == UX_PICTBRIDGE_ACTION_RESULT_OK)
{
/* Check what command we got back from the host. */
switch (pictbridge -> ux_pictbridge_input_request)
{
case UX_PICTBRIDGE_IR_CONFIGURE_PRINT_SERVICE :
/* Set event to configure print service. */
event_flag = UX_PICTBRIDGE_EVENT_FLAG_CONFIGURE_PRINT_SERVICE;
break;
case UX_PICTBRIDGE_IR_GET_CAPABILITY :
/* Set event to capability. */
event_flag = UX_PICTBRIDGE_EVENT_FLAG_CAPABILITY;
break;
case UX_PICTBRIDGE_IR_GET_JOB_STATUS :
/* Set event to capability. */
event_flag = UX_PICTBRIDGE_EVENT_FLAG_JOB_STATUS;
break;
case UX_PICTBRIDGE_IR_GET_DEVICE_STATUS :
/* Set event to device status. */
event_flag = UX_PICTBRIDGE_EVENT_FLAG_DEVICE_STATUS;
break;
case UX_PICTBRIDGE_IR_START_JOB :
/* Set event to start job . */
event_flag = UX_PICTBRIDGE_EVENT_FLAG_START_JOB;
break;
case UX_PICTBRIDGE_IR_ABORT_JOB :
/* Set event to abort job. */
event_flag = UX_PICTBRIDGE_EVENT_FLAG_ABORT_JOB;
break;
case UX_PICTBRIDGE_IR_CONTINUE_JOB :
/* Set event to continue job. */
event_flag = UX_PICTBRIDGE_EVENT_FLAG_CONTINUE_JOB;
break;
case UX_PICTBRIDGE_IR_NOTIFY_JOB_STATUS :
/* Set event to notify job status. */
event_flag = UX_PICTBRIDGE_EVENT_FLAG_NOTIFY_JOB_STATUS;
break;
case UX_PICTBRIDGE_IR_NOTIFY_DEVICE_STATUS :
/* Set event to notify device status. */
event_flag = UX_PICTBRIDGE_EVENT_FLAG_NOTIFY_DEVICE_STATUS;
break;
default :
/* Function not yet supported. */
break;
}
/* Send event to the application. */
_ux_system_event_flags_set(&pictbridge -> ux_pictbridge_event_flags_group, event_flag, UX_OR);
}
else
{
/* We have an error of some kind. Wake up the application with error event. */
_ux_system_event_flags_set(&pictbridge -> ux_pictbridge_event_flags_group, UX_PICTBRIDGE_EVENT_FLAG_ERROR, UX_OR);
}
/* What cycle are we in ? */
if (pictbridge -> ux_pictbridge_host_client_state_machine & UX_PICTBRIDGE_STATE_MACHINE_CLIENT_REQUEST)
{
/* Since we are in client request, this indicates we are done with the cycle. */
pictbridge -> ux_pictbridge_host_client_state_machine = UX_PICTBRIDGE_STATE_MACHINE_IDLE;
}
/* We have executed the script. */
return(UX_SUCCESS);
}
/* Could not find the handle. */
return(UX_DEVICE_CLASS_PIMA_RC_INVALID_OBJECT_HANDLE);
}
|