mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-27 04:43:52 +01:00
crc?
This commit is contained in:
@@ -4,9 +4,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -25,7 +25,7 @@ inline int _strncpy(char *dest, const char *src, int n) {
|
||||
}
|
||||
return i;
|
||||
}
|
||||
uint16_t crc16_ccitt(char* data, uint16_t len) {
|
||||
uint16_t crc16_ccitt(const char* data, uint16_t len) {
|
||||
uint16_t i, crc=0xFFFF;
|
||||
for (i=0; i < len; i++ ) {
|
||||
crc = (unsigned char)(crc >> 8) | (crc << 8);
|
||||
|
||||
@@ -8,7 +8,7 @@ void msleep(unsigned long ms);
|
||||
int _strnlen(const char *s, int maxlen);
|
||||
int _strncpy(char *dest, const char *src, int n);
|
||||
|
||||
uint16_t crc16_ccitt(char *data, uint16_t len);
|
||||
uint16_t crc16_ccitt(const char *data, uint16_t len);
|
||||
|
||||
uint16_t get_block_from_group(RDSGroup *group, uint8_t block);
|
||||
|
||||
|
||||
@@ -406,6 +406,13 @@ int lua_get_available_rds_streams(lua_State *localL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lua_crc16(lua_State *localL) {
|
||||
size_t len;
|
||||
const char* data = luaL_checklstring(localL, 1, &len);
|
||||
lua_pushinteger(localL, crc16_ccitt(data, len));
|
||||
return 1;
|
||||
}
|
||||
|
||||
void init_lua(RDSModulator* rds_mod) {
|
||||
static int mutex_initialized = 0;
|
||||
mod = rds_mod;
|
||||
@@ -524,6 +531,8 @@ void init_lua(RDSModulator* rds_mod) {
|
||||
lua_register(L, "get_userdata", lua_get_userdata);
|
||||
lua_register(L, "get_userdata_offset", lua_get_userdata_offset);
|
||||
|
||||
lua_register(L, "crc16", lua_crc16);
|
||||
|
||||
if (luaL_loadfile(L, "/etc/rds95.lua") != LUA_OK) {
|
||||
fprintf(stderr, "Lua error loading file: %s\n", lua_tostring(L, -1));
|
||||
lua_pop(L, 1);
|
||||
|
||||
Reference in New Issue
Block a user