Friday, August 28, 2009
Serial To Ethernet Gateway Part 1
Thursday, August 27, 2009
UDP Programming
#define MAX_BUF_SIZE 2048 // define maximum buffer size
uint8 xdata pDestaddr[4]; //xdata using external ram
uint16 xdata pPort; // destination port
uint8 xdata rcvLen; // length of data received
uint16 xdata length; // the length of data received
uint8 xdata RXdata[MAX_BUF_SIZE]; // RX data received
uint8 xdata TXData[MAX_BUF_SIZE]; // TX data send
uint16 xdata sentLen; // length of data sent
uint16 xdata TXSize; // size of string sent
Init_iMCU(); // Initialize iMCUW7100
Init_Network(); // Initialize Network Configuration
//Delay for link
wait_1ms(7000);
// 1. create socket for udp
if(socket(0, Sn_MR_UDP,5000, 0) == 1) // create socket with UDP port 5000
{
PutString("\r\n opened socket");
// 2. receive data
while(getSn_RX_RSR(0) == 0) ; // check if there is data in socket
PutString("\r\n got data");
rcvLen = getSn_RX_RSR(0);
if(rcvLen > MAX_BUF_SIZE) // check if data received is bigger than size of buffer string
rcvLen = MAX_BUF_SIZE; // assign max buffer size to the received length
PutString("\r\n RX data size is "); PutITOA(rcvLen); PutString(" Bytes.");
length = recvfrom(0, RXdata, rcvLen, pDestaddr, &pPort); // receive data
RXdata[length] = 0; // indicate the end of string
PutString("\r\n RX data : ");
PutString(RXdata); // print received data
// 3. trasnmit data
//set Dest. IP address & Port
pDestaddr[0]= 192;
pDestaddr[1]= 168;
pDestaddr[2]= 1;
pDestaddr[3]= 3;
pPort = 5000;
PutString("\r\n TX data size is ");PutITOA(TXSize);
sentLen = sendto(0, TXData, TXSize, pDestaddr, pPort); // transfer data
if (sentLen == TXSize)
PutString("\r\n success to transmit");
else
PutString("\r\n Failed to transmit");
}
else // if socket is fail
PutString("\r\n Failed to open socket");
Thursday, August 13, 2009
Casino in Singapore
Recently, I have been talking with some of our customers in Singapore. During the internet revolution, the Ethernet has pretty much conquered the PC market. Since Ethernet is such a popular and powerful interface, most of the embedded systems are following this trend as well.
One example application of using the Ethernet is in slot machines. In the Old days, when you walk into a Casino, you have to get change to play the slot machine. To avoid such inconvenience, a card is used in place of coins nowadays, so that you don’t have to insert coins every time you want to enjoy the slot machine. Once your card is inserted into the card reader, and you are ready to go. This card stores the number of credit you have left, so that you don’t have to carry loads of coins in your pocket. In fact, the slot machines are connected to each other by an Ethernet Network. Whenever you use your credits, they are automatically deducted from the central server’s data base.
No only this is a convenience from the customer’s point of view, but from the business point of view, you can also use this type of system to collect your customer’s data. Your customers are required to register their name, address and phone number in order to use this card. Since all of your customers’ playing records are recorded in your server, you can receive important marketing data such as how much they spend during their stay, Which day of the week they usually come?, What time of the day do they come most?, or How often do they come in a month? Once you have such important data, you can tailor-make your promotion activities to target specific customers. Perhaps, you can offer your customers a drink whenever they lose a certain amount of money! :)
Here is just one example of how our products can be applied in real life application. I hope you have enjoyed it! Please feel free to leave me your comments! Thanks! :)
FAE of WIZnet H.K.