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
|
#include <Container.h>
#include <DataDef.h>
#include <PMR/Common/MessageContainer.pb-c.h>
#include <PMR/Stubs/StubSteperMotorRequest.pb-c.h>
#include <PMR/Stubs/StubSteperMotorResponse.pb-c.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_uart.h"
#include "driverlib/gpio.h"
#include "Drivers/USB_Communication/USBCDCD.h"
#include "Stub_Status.h"
void Stub_SteperMotorRequest(MessageContainer* requestContainer)
{
uint32_t status = NOT_SUPPORTED;
MessageContainer responseContainer;
StubSteperMotorRequest* request = stub_steper_motor_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
/*
request->motorid
request->start
request->setdirection
request->setmicrostepdivision
request->setspeed
*/
StubSteperMotorResponse response = STUB_STEPER_MOTOR_RESPONSE__INIT;
response.motorid = request->motorid;
response.has_motorid = true;
response.motorversion = 123;
response.has_motorversion = true;
status_response(status,&response.status, &response.statusword ,&response.has_statusword);
responseContainer = createContainer(MESSAGE_TYPE__StubSteperMotorResponse, requestContainer->token, true, &response, &stub_steper_motor_response__pack, &stub_steper_motor_response__get_packed_size);
//-------------------------------------------------------------------------------------------
uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
size_t container_size = message_container__pack(&responseContainer, container_buffer);
free(responseContainer.data.data);
SendChars((char*)container_buffer, container_size);
//free(container_buffer);
//free(requestContainer);
stub_steper_motor_request__free_unpacked(request,NULL);
}
|