2
Fab@Home operates under the BSD Open Source License
4
Copyright (c) 2006, Hod Lipson and Evan Malone (evan.malone@cornell.edu) All rights reserved.
6
Redistribution and use in source and binary forms, with or without modification,
7
are permitted provided that the following conditions are met:
9
Redistributions of source code must retain the above copyright notice,
10
this list of conditions and the following disclaimer.
11
Redistributions in binary form must reproduce the above copyright notice,
12
this list of conditions and the following disclaimer in the documentation and/or
13
other materials provided with the distribution.
14
Neither the name of the Fab@Home Project nor the names of its contributors may be
15
used to endorse or promote products derived from this software without specific
16
prior written permission.
18
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
#include ".\configurepacket.h"
33
IMPLEMENT_DYNAMIC(CConfigurePacket, CPacket)
35
CConfigurePacket::CConfigurePacket(void)
39
CConfigurePacket::~CConfigurePacket(void)
43
bool CConfigurePacket::InitPacket(BOOL *limSw)
45
//call the base class Init fn FIRST!!!!
46
//it fills in the packet code, so we need to overwrite it afterward
47
if(!CPacket::InitPacket()) return false;
49
//always remember to overwrite the packet type
50
m_enumPktCode = CONFIG;
52
//define which axes and directions have hardware limit switches
53
//should be read in from printer definition file
55
m_hwLimits.flags.X_FWD = limSw[i++];
56
m_hwLimits.flags.X_BKD = limSw[i++];
57
m_hwLimits.flags.Y_FWD = limSw[i++];
58
m_hwLimits.flags.Y_BKD = limSw[i++];
59
m_hwLimits.flags.Z_FWD = limSw[i++];
60
m_hwLimits.flags.Z_BKD = limSw[i++];
61
m_hwLimits.flags.U_FWD = limSw[i++];
62
m_hwLimits.flags.U_BKD = limSw[i++];
63
m_hwLimits.flags.V_FWD = limSw[i++];
64
m_hwLimits.flags.V_BKD = limSw[i++];
65
m_hwLimits.flags.W_FWD = limSw[i++];
66
m_hwLimits.flags.W_BKD = limSw[i++];
71
bool CConfigurePacket::PacketToStream(BYTE *buf, unsigned int *size)
73
//convert the packet into a stream of bytes
74
//return a stream of bytes in *buf, and true if successful
75
//*size should pass in the maximum space available in the buffer
76
//and will be used to return the number of bytes written
77
if( (buf == NULL) || (size == NULL) || (*size < m_bytePktSize) )
80
//call the base class PacketToStream to handle the common members
81
unsigned int cnt = *size;
82
if(!CPacket::PacketToStream(buf,&cnt))
85
//now fill in the derived class members
87
//which axes/directions have hardware limit switches?
88
buf[cnt++] = m_hwLimits.data.B.B0;
89
buf[cnt++] = m_hwLimits.data.B.B1;
91
if(cnt > *size) return false;
97
bool CConfigurePacket::StreamToPacket(BYTE *buf, unsigned int *size)
99
//convert a stream of bytes into a packet
100
//read data from *buf as a stream of bytes
101
//*size should pass in the length of the data in the buffer in bytes
102
//and will be used to return the number of bytes read
103
//return true if successful
104
if( (buf == NULL) || (size == NULL) || (*size < m_bytePktSize) )
107
//call the base class StreamToPacket to handle the common members
108
unsigned int cnt = *size;
109
if(!CPacket::StreamToPacket(buf,&cnt))
112
//now fill in the derived class members
114
//which axes/directions have hardware limit switches?
115
m_hwLimits.data.B.B0 = buf[cnt++];
116
m_hwLimits.data.B.B1 = buf[cnt++];
118
if(cnt > *size) return false;
b'\\ No newline at end of file'